Mr. Lendem is studying the genetics of odor in Guavas (Psidium guajava).He knows that the D gene, controlling odor, follows Mendelian inheritance so that DD Guavas have a strong typical smell, Dd plants have weaker smell and dd plants don't smell at all.
Write a program that, given a number of Guava plants examined, will calculate and print the expected numbers of smelly, less smelly and non-smelly plants (according to the Mendelian 1:2:1 inheritance law).
plants_num = 145 # Replace ??? with a value of your choice.
smelly = int(0.25*plants_num)
less_smelly = int(0.5*plants_num)
non_smelly = int(0.25*plants_num)
print('Smelly:',smelly)
print('Less smelly:',less_smelly)
print('Non Smelly:',non_smelly)
Smelly: 36 Less smelly: 72 Non Smelly: 36
b) something similar with two genes...
Each individual has either blood type 'A', 'B', 'AB' or 'O'.
Blood donations may be received from individuals with the same blood type, although 'AB' may receive all types and 'O' may donate to all types.
Write a program that, given the blood types of two patients, prints whether the recepient may receive a blood donation from the donor. The program should print 'True' if a donation is possible, 'False' if it isn't, and 'Invalid input' if one of the blood types is not 'A', 'B', 'AB' or 'O' (only accept uppercase letters.
recepient_blood_type = 'O' # Replace ??? with a value of your choice.
donor_blood_type = 'B' # Replace ??? with a value of your choice.
# make sure that input blood types are valid
if (recepient_blood_type != 'A' and recepient_blood_type != 'B' and recepient_blood_type != 'AB' and recepient_blood_type != 'O') \
or (donor_blood_type != 'A' and donor_blood_type != 'B' and donor_blood_type != 'AB' and donor_blood_type != 'O'):
print ("Invalid input")
# if they are valid
else:
# if they same blood type, or recepient is AB or donor is O, donation is OK
if recepient_blood_type == donor_blood_type or recepient_blood_type == 'AB' or donor_blood_type == 'O':
print(True)
# else, donation is not OK
else:
print(False)
False
In Dr. Dre's lab, there are X students, each uses Y Petri dishes a day, on average. At the begining of each month, the lab manager has to decide if he/she should order more dishes. Given the number of students (X), the average number of dishes they use per day (Y) and the number of dishes in stock (N), write a program that will make the decision, using the following rules:
Print the total number of dishes that should be ordered.
students = 6 # Replace ??? with a value of your choice.
dishes_per_student = 65 # Replace ??? with a value of your choice.
dishes_in_stock = 425 # Replace ??? with a value of your choice.
one_month_supply = students * dishes_per_student
if dishes_in_stock > 2 * one_month_supply:
dishes_to_order = 0
elif one_month_supply < dishes_in_stock < 2 * one_month_supply:
dishes_to_order = 2 * one_month_supply - dishes_in_stock
elif dishes_in_stock < one_month_supply:
dishes_to_order = 3 * one_month_supply - dishes_in_stock
print('Order',dishes_to_order,'dishes')
Order 355 dishes