Write My Paper Button

WhatsApp Widget

FIN551: Python Programming Overview of exercise 1: Given below is a list of numbers consisting of areas of multiple rectangles whose sides are integers For example, is X is an area of the rectangle given by the formula X = A * B here: A = Integer and B = Integer rect_100 = list(range(100)) rect_100 = [i + 1 for i in num_100] 1. Write a function to see if a given rectang

FIN551: Python Programming

Overview of exercise 1:

Given below is a list of numbers consisting of areas of multiple rectangles whose sides are integers

For example, is X is an area of the rectangle given by the formula
X = A * B here:
A = Integer and B = Integer

rect_100 = list(range(100))
rect_100 = [i + 1 for i in num_100]

1. Write a function to see if a given rectangle can be a given square (Hint: Check if the number is a perfect square)
2. Write a function to extract all rectangles that are square ((Hint: Use the function in step 1)

#Write a function to check if a given rectangle is a perfect square
def get_squares_check(n):

#Calculate the square root of “n”
# Use the functionality of power using “**” to get the square root

# Use the in built function “round” to round of the square root to an integer
#Round the square root to an integer

#Check if the square of the rounded square root of number “n” is the same as “n”
#If the value is same assign “True” as value to sqr_flag
#If the value is not the same assign “False” as value to sqr_flag

return flag

#Extact the list of squared rectangles
def get_square_list(num_list):
#Create an empty list to save the squared rectangles
#Iterate between all the rectangular areas in the list

#Check if the rectangule is a square using the function ‘get_squares_check” declared above
#Check if the value of the sqr_check is True
#If value of the prime_check is True then append “n” to the sqr_list declared earlier

return square_list

Overview of exercise 2:
Given below is a list of numbers
1. Write a function to check if a number is a prime number
2. Write a function to determine all the prime numbers in the list

apple_qty =

[233,160,23,181,156,289,70,39,122,40,93,21,204,185,253,267,139,
79,176,259,290,83,278,111,221,20,242,49,295,256,186,46,268,161
227,249,157,19,33,43,129,84,165,182,87,159,37,231,191,128,110,
36,169,275,133,94,293,140,112,291,206,288,262,104,296,32,16,299
69,135,67,98,209,28,114,294,95,89,138,211,109]

#define a function to return all the prime numbers for number greater than 2
def get_prime_check(n):

#Get the square root of the number “n” and take it’s ceiling
# Use the functionality of power using “**” to get the square root
#Create an empty flag with value as “False”
#Iterate between 2 and (n_sqrt+1) iterated to check if the number is a prime number
#Check if the remainder upon dividing the number “n” with the iterative number “i” is zero

#If zero then remainder is 0, then chnage the prime flag to true
#Return the flag that checks if a number is prime
return prime_flag

#define a function to return all the prime numbers for number greater than 2
def get_prime_list(num_list):
#Create an empty list to save the prime numbers iterated
#Iterate between all the numbers in the list
#If “n” == 1 then skip the iteration then move to the next number in sequence using the “pass” statement
#If “n” == 2 then add it to the prime_list and skip the iteration to move to the next number in sequence
#Use the “get_prime_check” function to check if numbers greater than 2 are prime
#Check if the number is prime
#Check the value of the prime_check is True
#If value of the prime_check is True then append “n” to the prime_list declared earlier
return prime_list

The two list consists of Birthdays (DOB_List) of the research scientists (Name_List) in the same order
1. Build a dictionary that holds the scientist name as key and their DOB as their values
2. Create a dictionary consisting of the approximate age of the scientists today in years (use only years)

dob_list = [’01-Jan-1990′, ’11-Aug-1995′, ’15-Apr-1982′, ’20-Mar-1988′, ’25-Nov-1976′
’18-Dec-1977′, ’25-May-1994′, ’09-Oct-1981′, ’19-Feb-1981’]
name_list = [‘Aaron’,’Ben’,’Don’,’Grisham’,’Harry’,’John’,’Tom’,’Peter’,’S

Create a an empty dictionary

#Store the values in the dictionary using names as keys and dates as values

####Create a an empty dictionary
#Declare the current year
#Run a for loop to calculate the approximate age for every scientist

#Extract year from the Date of birth using “split” functionality

#Calculate approximate age in year using the year of birth and store it

CLAIM YOUR 30% OFF TODAY

X
Don`t copy text!
WeCreativez WhatsApp Support
Our customer support team is here to answer your questions. Ask us anything!
???? Hi, how can I help?