[SOLVED] CS计算机代考程序代写 python A1_2021WinterB

30 $

File Name: CS计算机代考程序代写_python_A1_2021WinterB.zip
File Size: 480.42 KB

SKU: 3392239908 Category: Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Or Upload Your Assignment Here:


A1_2021WinterB

ALY6140 2021WinterB Assignment 1¶
Download the “A1_2021WinterB.ipynb” notebook
Fill in the code in the cells marked with # YOUR ANSWER HERE: by answering the question/task defined in the cell above it starting with GRADED:
Code cells outside of # YOUR ANSWER HERE: will not be considered for grading. Feel free to write outside of it for debugging

Submit the updated notebookMake 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:¶
completely defined: add_numbers;
partially defined: mul_numbers; and
not defined at all: exp_numbers

Complete mul_numbers so that it return product of two numbers

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 [ ]:

# YOUR ANSWER HERE:

def add_numbers(a, b):
“””
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!

GRADED [2]:¶
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.

Hint: Your string shold follow the Python formatting functionality. https://pyformat.info/

In [ ]:

# YOUR ANSWER HERE
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

GRADED [3]:¶
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 [ ]:

# YOUR ANSER HERE

GRADED [4]:¶
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 [ ]:

# YOUR ANSER HERE:

GRADED [5]:¶
Given the following dictionary, please calcuate the average annual salary for those CEOs.

In [ ]:

company_dict = {
‘Satya Nadella’: [‘Microsoft’, ‘$42,910,215’],
‘Jeff Bezos’: [‘Amazon’, ‘$81,840’],
‘Tim Cook’: [‘Apple’, ‘$3,000,000’]
}

In [ ]:

# YOUR ANSER HERE:

GRADED [6]:¶
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 [ ]:

# YOUR ANSWER HERE:

GRADED [7]:¶
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 [ ]:

#YOUR ANSWER HERE:

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] CS计算机代考程序代写 python A1_2021WinterB
30 $