# CS计算机代考程序代写 python ALY6140 2021WinterB Assignment 1¶

ALY6140 2021WinterB Assignment 1¶
▪ Feel free to write outside of it for debugging
• Submit the updated notebook
▪ Make sure to save your changes before submitting it!
▪ Rename the notebook as “A1_firstname_lastname.ipynb”
In [ ]:
#Import necessary libraries
import pandas as pd
import numpy as np

GRADED [1]: Provided below are functions that are:¶
• partially defined: mul_numbers; and
• not defined at all: exp_numbers
1. Complete mul_numbers so that it return product of two numbers
2. Write a function called exp_numbers
▪ Do exponention calcuation. Return a to the power of b. a is the first argument, while b is the second.
▪ Print warning message if b is greater than 100 – “Are you sure to use this number!”
In [ ]:

“””
Calculate the sum of a and b
“””
result = a + b
return result

def mul_numbers(a, b):
“””
Calculate the multiplation of a and b
“””
result = a * b
return result

def exp_numbers(a, b):
“””
calculate the result of a to the power of b
“””
result = a ** b
return result
“””
Warning message: Are you sure to use this number!

Write a function called show_info that takes a name, a home city, and a home state (a total of 3 arguments) and returns a full sentence string with the following content and format: Hello [name] and you hometown is [city] in [state].
• Please make sure that you follow the format of the sentence exactly as defined
• Properly capitalize the city name
• Import dictionary states from utilities.py and transform the two letter abbreviation of the home state into the full name of the state.
• Please remove the extra leading or trailing spaces in the name, city or state.
In [ ]:
def show_info(name,city,state):
return f’Your name is {name} and you live in {city}, {state}.’
In [ ]:
show_info(‘Jane Austen ‘, ‘gloucester ‘, ‘ ma ‘) # please do not modify this cell

Find out all the twin prime pairs under 100 and save all the pairs into a list twin_primes.
Hint: (3,5) is the first pair of twim prime
In [ ]:

Using a while loop to loop over and print every element in a given list started from the last element.
Then repeat the same operation with a for loop
In [ ]:
lst4 = [‘Value:’, ‘\$4’, ‘Profit:’, ‘\$1’]
In [ ]:

Given the following dictionary, please calcuate the average annual salary for those CEOs.
In [ ]:
company_dict = {
‘Jeff Bezos’: [‘Amazon’, ‘\$81,840’],
‘Tim Cook’: [‘Apple’, ‘\$3,000,000’]
}
In [ ]:

Body mass index (BMI) is a convenient and inexpensive tool to screen various weight conditions – underweight, healthy weight, overweight, and obesity.
Please write a function called bmi_calculator that takes three argument:
• height_feet (feet)
• height_inch (inches)
• weight (pounds)
The function will return a corresponding BMI value. The BMI value should be rounded to the nearest whole number.
Please call the function and generate the following message: Your height is […] feet and […] inches, and your weight is […] pounds. You BMI is […]
In [ ]:

Build a dictionary patron_dict to read in the library patrons information stored in a list patrons
For each element in the list, the first number is the patron id, the next is the name of the book or DVD the patron borrowed.
Please use patron id as key, and book or DVD name as associated value in the dictionary to combine these information.
Please show the newly created dictionary in an ascending order based on patron id.
Hint:
• Please apply proper methods to remove the leading and trailing spaces in the patron id or the name of the book or DVD
In [ ]:
patrons = [“005 , Catch-22 “, ” 002, The Long Goodbye “, “001 , The Shawshank Redemption “,
“008 , The Grapes of Wrath “, “061 , The Catcher in the Rye “,
“010 , The Sun Also Rises “, “021 , Barbarians at the Gate”,
“009 , The Myth of Sisyphus”]
for i in patrons:
print(i)
In [ ]: