Question 1 you decided to make a new investment and buy a condo. you will be ren

Question 1
You decided to make a new investment and buy a condo. You will be renting it out for 35,000 SAR per month. You want to create a program that take the rent amount as an input. Then, calculate the total income that you will receive in 10 years and print out the total for the user.
Question 2
To gain customer loyalty you decided to offer special discounts for loyal customers. Also, offer special discount for new customers to encourage them to stay in business.
Your discount policy will be as the following:
Customer who have less than 100 loyalty points will receive 10% discount.
Customers who have more than 1000 loyalty point will also receive 10% discount.
Create a program that will ask the user to enter their names and how many points do they have. Based on the
collected information, you will print out a message stating if this customer is eligible for discount or not.
Question 3
The ministry of education is trying to encourage a multicultural environment in the school system. To do so, each school has to report the total number of Saudi and non-Saudi students in their classes.
Your job as a programmer is to design a programme to help each instructor with this task.
The program will ask each student to identify their nationality. For example, a question will ask if the student of Saudi nationality or not. The user will answer “Y” for yes and “N” for no. Then calculate the total number of each entry and display it at the end of the program. Keep in mind that the logic of the program will allow the user to continuously enter a value until X is entered.
Question 4
The following list contains a mix of names of countries and cities. Each name is followed by a letter about whether it is part of the GCC countries or European Union.
mixed = [“Bahrain G”, “Austria E”, “Qatar G”, “Malta E”, “Italy E”, “Oman G”, “Kuwait G”, “Denmark E”, “France E”]
Write a program that creates two lists (one of GCC countries, and one of EU) and uses the lists to produce the output.See the file

I will share with you all the answered questions and all the codes.

There are 7 questions I solve them all
just the last question (Q7) I couldn’t that shown below:
Develop a program to accept from the user the features and give the prediction for all the classifiers including the ensemble classifier. Comment on the results
I will share with you all the answered questions and all the codes.

List average execution time array average execution time 1

Assignment 7b – Array Oriented Programming
Question #1:
(Flattening arrays with flatten vs. ravel) Create a 2-by-3 array containing the
first six powers of 2 beginning with 20. Flatten the array first with method flatten, then
with ravel. In each case, display the result then display the original array to show that it
was unmodified.
Question #2
(Horizontal and Vertical Stacking) Create the two-dimensional arrays
array1 = np.array([[0, 1], [2, 3]])
array2 = np.array([[4, 5], [6, 7]])
a) Use vertical stacking to create the 4-by-2 array named array3 with array1
stacked on top of array2.
b) Use horizontal stacking to create the 2-by-4 array named array4 with array2
to the right of array1.
c) Use vertical stacking with two copies of array4 to create a 4-by-4 array5.
d) Use horizontal stacking with two copies of array3 to create a 4-by-4 array6.
Question #3
(Shallow vs. Deep Copy) In this lecture, we discussed shallow vs. deep copies of
arrays. Python’s built-in list and dictionary types have copy methods that perform shallow
copies. Using the following dictionary
dictionary = {‘Sophia’: [97, 88]}
demonstrate that a dictionary’s copy method indeed performs a shallow copy. To do so,
call copy to make the shallow copy, modify the list stored in the original dictionary, then
display both dictionaries to see that they have the same contents.
Next, use the copy module’s deepcopy function to create a deep copy of the dictionary.
Modify the list stored in the original dictionary, then display both dictionaries to
prove that each has its own data.
Question #4
(Performance Analysis) In this chapter, we used %timeit to compare the average execution
times of generating a list of 6,000,000 random die rolls vs. generating an array of
6,000,000 random die rolls. Though we saw approximately two orders of magnitude performance
improvement with array, we generated the list and the array using two different random-
number generators and different techniques for building each collection. If you use the
same techniques we showed to generate a one-element list and a one-element array, creating
the list is slightly faster. Repeat the %timeit operations for one-element collections. Then do
it again for 10, 100, 1000, 10,000, 100,000, and 1,000,000 elements and compare the results
on your system
Please fill the below table and discuss which is better.
Number of Values
List average execution time
array average execution time
1
10
100
1000
10,000
100,000
1,000,000
Question #5
(Pandas: Series) Perform the following tasks with pandas Series:
a) Create a Series from the list [7, 11, 13, 17].
Number of values List average execution time array average execution time
1 1.56 μs ± 25.2 ns 1.89 μs ± 24.4 ns
10 11.6 μs ± 59.6 ns 1.96 μs ± 27.6 ns
100 109 μs ± 1.61 μs 3 μs ± 147 ns
1000 1.09 ms ± 8.59 μs 12.3 μs ± 419 ns
10,000 11.1 ms ± 210 μs 102 μs ± 669 ns
100,000 111 ms ± 1.77 ms 1.02 ms ± 32.9 μs
1,000,000 1.1 s ± 8.47 ms 10.1 ms ± 250 μs
Exercises 279
b) Create a Series with five elements that are all 100.0.
c) Create a Series with 20 elements that are all random numbers in the range 0 to
100. Use method describe to produce the Series’ basic descriptive statistics.
d) Create a Series called temperatures of the floating-point values 98.6, 98.9,
100.2 and 97.9. Using the index keyword argument, specify the custom indices
‘Julie’, ‘Charlie’, ‘Sam’ and ‘Andrea’.
e) Form a dictionary from the names and values in Part (d), then use it to initialize
a Series.
Question # 6
(Pandas: DataFrames) Perform the following tasks with pandas DataFrames:
a) Create a DataFrame named temperatures from a dictionary of three temperature
readings each for ‘Maxine’, ‘James’ and ‘Amanda’.
b) Recreate the DataFrame temperatures in Part (a) with custom indices using
the index keyword argument and a list containing ‘Morning’, ‘Afternoon’
and ‘Evening’.
c) Select from temperatures the column of temperature readings for ‘Maxine’.
d) Select from temperatures the row of ‘Morning’ temperature readings.
e) Select from temperatures the rows for ‘Morning’ and ‘Evening’ temperature
readings.
f) Select from temperatures the columns of temperature readings for ‘Amanda’
and ‘Maxine’.
g) Select from temperatures the elements for ‘Amanda’ and ‘Maxine’ in the
‘Morning’ and ‘Afternoon’.
h) Use the describe method to produce temperatures’ descriptive statistics.
i) Transpose temperatures.
j) Sort temperatures so that its column names are in alphabetical order.

List average execution time array average execution time 1

Question #1:
(Flattening arrays with flatten vs. ravel) Create a 2-by-3 array containing the
first six powers of 2 beginning with 20. Flatten the array first with method flatten, then
with ravel. In each case, display the result then display the original array to show that it
was unmodified.
Question #2
(Horizontal and Vertical Stacking) Create the two-dimensional arrays
array1 = np.array([[0, 1], [2, 3]])
array2 = np.array([[4, 5], [6, 7]])
a) Use vertical stacking to create the 4-by-2 array named array3 with array1
stacked on top of array2.
b) Use horizontal stacking to create the 2-by-4 array named array4 with array2
to the right of array1.
c) Use vertical stacking with two copies of array4 to create a 4-by-4 array5.
d) Use horizontal stacking with two copies of array3 to create a 4-by-4 array6.
Question #3
(Shallow vs. Deep Copy) In this lecture, we discussed shallow vs. deep copies of
arrays. Python’s built-in list and dictionary types have copy methods that perform shallow
copies. Using the following dictionary
dictionary = {‘Sophia’: [97, 88]}
demonstrate that a dictionary’s copy method indeed performs a shallow copy. To do so,
call copy to make the shallow copy, modify the list stored in the original dictionary, then
display both dictionaries to see that they have the same contents.
Next, use the copy module’s deepcopy function to create a deep copy of the dictionary.
Modify the list stored in the original dictionary, then display both dictionaries to
prove that each has its own data.
Question #4
(Performance Analysis) In this chapter, we used %timeit to compare the average execution
times of generating a list of 6,000,000 random die rolls vs. generating an array of
6,000,000 random die rolls. Though we saw approximately two orders of magnitude performance
improvement with array, we generated the list and the array using two different random-
number generators and different techniques for building each collection. If you use the
same techniques we showed to generate a one-element list and a one-element array, creating
the list is slightly faster. Repeat the %timeit operations for one-element collections. Then do
it again for 10, 100, 1000, 10,000, 100,000, and 1,000,000 elements and compare the results
on your system
Please fill the below table and discuss which is better.
Number of Values
List average execution time
array average execution time
1
10
100
1000
10,000
100,000
1,000,000
Question #5
(Pandas: Series) Perform the following tasks with pandas Series:
a) Create a Series from the list [7, 11, 13, 17].
Number of values List average execution time array average execution time
1 1.56 μs ± 25.2 ns 1.89 μs ± 24.4 ns
10 11.6 μs ± 59.6 ns 1.96 μs ± 27.6 ns
100 109 μs ± 1.61 μs 3 μs ± 147 ns
1000 1.09 ms ± 8.59 μs 12.3 μs ± 419 ns
10,000 11.1 ms ± 210 μs 102 μs ± 669 ns
100,000 111 ms ± 1.77 ms 1.02 ms ± 32.9 μs
1,000,000 1.1 s ± 8.47 ms 10.1 ms ± 250 μs
Exercises 279
b) Create a Series with five elements that are all 100.0.
c) Create a Series with 20 elements that are all random numbers in the range 0 to
100. Use method describe to produce the Series’ basic descriptive statistics.
d) Create a Series called temperatures of the floating-point values 98.6, 98.9,
100.2 and 97.9. Using the index keyword argument, specify the custom indices
‘Julie’, ‘Charlie’, ‘Sam’ and ‘Andrea’.
e) Form a dictionary from the names and values in Part (d), then use it to initialize
a Series.
Question # 6
(Pandas: DataFrames) Perform the following tasks with pandas DataFrames:
a) Create a DataFrame named temperatures from a dictionary of three temperature
readings each for ‘Maxine’, ‘James’ and ‘Amanda’.
b) Recreate the DataFrame temperatures in Part (a) with custom indices using
the index keyword argument and a list containing ‘Morning’, ‘Afternoon’
and ‘Evening’.
c) Select from temperatures the column of temperature readings for ‘Maxine’.
d) Select from temperatures the row of ‘Morning’ temperature readings.
e) Select from temperatures the rows for ‘Morning’ and ‘Evening’ temperature
readings.
f) Select from temperatures the columns of temperature readings for ‘Amanda’
and ‘Maxine’.
g) Select from temperatures the elements for ‘Amanda’ and ‘Maxine’ in the
‘Morning’ and ‘Afternoon’.
h) Use the describe method to produce temperatures’ descriptive statistics.
i) Transpose temperatures.
j) Sort temperatures so that its column names are in alphabetical order.

Write answers in your own words.

Please send the answers in 7-hours. Just 4 questions and you can find a lot of information from online
nd for this lab you need:
Need submit lab9.py file (all questions code inside) and document pdf or Microsoft word lab9
Use Sublime text editor to write your code and use Python shell to execute below programs. Attach Snipping photos of your source code and executions of the code in Python shell.(each question have each one screenshot with code and test all pass have one of screenshot too. I willsend example picture put in the below.)
Make a copy of the assignment template. Go to File => Make a copy (or download as a Word file.)
Complete definitions and attach Snipping Photos where appropriate
Use the book or do online research to find answers.
Write your answers using a different font color. Find your own unique color.
Write answers in your own words. DO NOT COPY & PASTE from anywhere.
Submission: When done, go to File -> Download as -> Microsoft Word
Lab 09 – Generators – Linked Lists – Trees
Q1: Scale
Implement the generator function scale(s, k), which yields elements of the given iterable s, scaled by k. As an extra challenge, try writing this function using a yield from statement!
def scale(s, k):
“””Yield elements of the iterable s scaled by a number k.
>>> s = scale([1, 5, 2], 5)
>>> type(s)

>>> list(s)
[5, 25, 10]
>>> m = scale(naturals(), 2)
>>> [next(m) for _ in range(5)]
[2, 4, 6, 8, 10]
“””
“*** YOUR CODE HERE ***”
Q2: Link to List
Write a function link_to_list that takes in a linked list and returns the sequence as a Python list. You may assume that the input list is shallow; none of the elements is another linked list.
Try to find both an iterative and recursive solution for this problem!
def link_to_list(link):
“””Takes a linked list and returns a Python list with the same elements.
>>> link = Link(1, Link(2, Link(3, Link(4))))
>>> link_to_list(link)
[1, 2, 3, 4]
>>> link_to_list(Link.empty)
[]
“””
“*** YOUR CODE HERE ***”
Q3: Cumulative Sum
Write a function cumulative_sum that mutates the Tree t so that each node’s label becomes the sum of all labels in the subtree rooted at the node.
def cumulative_sum(t):
“””Mutates t so that each node’s label becomes the sum of
all labels in the corresponding subtree rooted at t.
>>> t = Tree(1, [Tree(3, [Tree(5)]), Tree(7)])
>>> cumulative_sum(t)
>>> t
Tree(16, [Tree(8, [Tree(5)]), Tree(7)])
“””
“*** YOUR CODE HERE ***”
Q4: Is BST
Write a function is_bst, which takes a Tree t and returns True if, and only if t is a valid binary search tree, which means that:
Each node has at most two children (a leaf is automatically a valid binary search tree)
The children are valid binary search trees
For every node, the entries in that node’s left child are less than or equal to the label of the node
For every node, the entries in that node’s right child are greater than the label of the node
Note that, if a node has only one child, that child could be considered either the left or right child. You should take this into consideration.
Hint: It may be helpful to write helper functions bst_min and bst_max that return the minimum and maximum, respectively, of a Tree if it is a valid binary search tree.
def is_bst(t):
“””Returns True if the Tree t has the structure of a valid BST.
>>> t1 = Tree(6, [Tree(2, [Tree(1), Tree(4)]), Tree(7, [Tree(7), Tree(8)])])
>>> is_bst(t1)
True
>>> t2 = Tree(8, [Tree(2, [Tree(9), Tree(1)]), Tree(3, [Tree(6)]), Tree(5)])
>>> is_bst(t2)
False
>>> t3 = Tree(6, [Tree(2, [Tree(4), Tree(1)]), Tree(7, [Tree(7), Tree(8)])])
>>> is_bst(t3)
False
>>> t4 = Tree(1, [Tree(2, [Tree(3, [Tree(4)])])])
>>> is_bst(t4)
True
>>> t5 = Tree(1, [Tree(0, [Tree(-1, [Tree(-2)])])])
>>> is_bst(t5)
True
>>> t6 = Tree(1, [Tree(4, [Tree(2, [Tree(3)])])])
>>> is_bst(t6)
True
>>> t7 = Tree(2, [Tree(1, [Tree(5)]), Tree(4)])
>>> is_bst(t7)
False
“””
“*** YOUR CODE HERE ***”

Plt.show()

hi please help with this hw using the follow istructions is attached
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from sklearn.cluster import KMeans
from sklearn.preprocessing import StandardScaler
file_location = “C:\Users\Lenovo\Desktop\WMU Courses\Const. Informatics\HW6\ CCE_6960_Assignment 6\Bridge Data.xlsx”
OriginalDataset = pd.read_excel(file_location)
OriginalDataset.head()
print(OriginalDataset)
# function of Kmeans ———————
def Kmeans (k,data):
df = StandardScaler().fit_transform(data)
# print(scaled_df[:5])
kmeans = KMeans(n_clusters=3)
#predict the labels of clusters
label = kmeans.fit_predict(data)
# getting unique labels
u_labels = np.unique(label)
#plotting the result
for i in u_labels:
plt.scatter(df[label== i , 0],df[label == i ,1],label = i)
plt.legend()
plt.show()
Kmeans(3,OriginalDataset)

Summarize the characteristics of these data in time and space.

Ride-hailing platforms don’t have a constant price like public transportation like subways/buses. The price of a ride depends on factors such as mileage, time, demand, climate conditions and local accessibility.
We have two data sets, one week long, that include travel data from both Uber and Lyft and weather data over the same period. Please try the analysis according to the data content and the actual map location information:
· The relationship between trip length and price
· The relationship between price and climate
· The relationship between itinerary type and price
Summarize the characteristics of these data in time and space. For example, what is the common direction of migration in the morning? What is the common direction of migration in the evening? Are there specific differences between weekday and weekend schedules? Summarize a report and try to give statistics and solutions to optimize operations for drivers.

Select a landscape scene that you would like to draw using turtle graphics.

Select a landscape scene that you would like to draw using turtle graphics. This can be a simple forest scene, mountain scene, even an outer space scene – it’s up to you!
Import the turtle graphics module and set up your turtle canvas using the turtle.setup() function (see the lecture slides and our course website for some sample code to get you started).
Fill the background with a solid color other than white (hint: draw a filled box on your canvas before you draw anything else)
Create at least 5 different shapes (other than the background color from step #3) for your scene. For example, if you wanted to create a forest scene, you could create clouds, trees, a stream, the sun and some mountains for the background. Each shape MUST be written using a function that accepts at least one or more argument(s). You cannot simply call turtle commands from your main program for your shapes – every object should be rendered using its own function.
I have chosen to create a Christmas themed landscape. The 6 shapes will be a Christmas tree, snowman(3 circles), star on top of the tree, gifts under the tree, and a string of lights going across the scene, and clouds I want the snow to fall down. Ask the user a question for each shape:Do you want a Christmas Tree? – add circle ornaments to this tree
Do you want a snowman? (add buttons and a nose, and some arms)
Do you want to add a star to the tree?
Do you want gifts under the tree? If yes –> how many gifts under the tree (make it < 7) Do you want Christmas lights? Do you want clouds?