Question

In: Computer Science

5. Write a program that prints all numbers between 27 and 78, one number per line....

5. Write a program that prints all numbers between 27 and 78, one number per line.

6. In questions 6,7 the following list is used: [1,2,5,6,3,77,9,0,3,23,0.4,-12.4,-3.12]

7. Using “for” loop, write program that finds the smallest number in the list.

8. Using “for” loops, calculate arithmetic mean of all numbers in the list. Do not use built-in function in Python.

9. For this question envision you are creating a dummy alert to help the doctor determine if patient needs a mammogram or not: Ask the user to answer the following questions:

• "What is your patient’s gender? Please answer F for female, M for male " and store it in a variable "gender".

• "What is your patient’s age? " store it in a variable "age"

• "Does your patient have family history of breast cancer? Please answer with True or False " store it in a variable name "history" The program should display the following alert messages based on conditions:

• If patient is female and over 40 the system should alert the doctor to "consider ordering mammogram”

• If the patient is female but younger than 40 the program should go to next step and consider patient family history to determine if mammogram is recommended. If patient has family history of breast cancer the program should display a message "consider mammogram because of family history". If not just display "my not need mammogram" • In any other case the alert should say "no mammogram order recommended". Suggestion: Attention to the variable types when you input and compare.

Solutions

Expert Solution

I have written the program using PYTHON PROGRAMMING LANGUAGE.

OUTPUT :

CODE :

#Question 5

# for loop to print the numbers from 27 to 78 inclusive

for number in range(27,78+1):

print(number)#to print on console

#Question 6,7,8

#declared required variables

mean = 0

length = 0

smallest = 9999999

list_numbers = [1,2,5,6,3,77,9,0,3,23,0.4,-12.4,-3.12]

for number in list_numbers:

length+=1

if(smallest> number):

smallest = number#smallest number

mean +=number

mean = mean / length#mean

print("\nSmallest Number in the list is {:.2f}\nMean of all numbers {:.2f}".format(smallest,mean))

#Question 9

#taking user input for gender age and history

gender = input("\nWhat is your patient’s gender? Please answer F for female, M for male : ")

age = int(input("What is your patient’s age? : "))

history = input("Does your patient have family history of breast cancer? Please answer with True or False : ")

#written conditions based on the description given in the question.

print("\n")

if(gender.lower() == "f" and age>=40):

print("consider ordering mammogram")

elif(gender.lower() == "f" and age<40):

if(history.lower() == "true"):

print("consider mammogram because of family history")

else:

print("may not need mammogram")

else:

print("no mammogram order recommended")

Thanks..


Related Solutions

Write a c++ program that prints the count of all prime numbers between A and B...
Write a c++ program that prints the count of all prime numbers between A and B (inclusive), where A and B are defined as follows: A = Any 5 digit unique number B = A + 1000 Just a recap on prime numbers: A prime number is any number, greater or equal to 2, that is divisible ONLY by 1 and itself. Here are the first 10 prime numbers: 2, 5, 7, 11, 13, 17, 19, 23, and 29. Rules:...
Write a program that finds and prints all of the prime numbers between 3 and X...
Write a program that finds and prints all of the prime numbers between 3 and X (X is input from the user). A prime number is a number such that 1 and itself are the only numbers that evenly divide it (for example, 3, 5, 7, 11, 13, 17, …). One way to solve this problem is to use a doubly nested loop (a loop inside another loop). The outer loop can iterate from 3 to N while the inner...
Write a program that prints the count of all prime numbers between A and B (inclusive),...
Write a program that prints the count of all prime numbers between A and B (inclusive), where A and B are defined as follows: A = The 5 digit unique number you had picked at the beginning of the semester B = A + 5000 Just a recap on prime numbers: A prime number is any number, greater or equal to 2, that is divisible ONLY by 1 and itself. Here are the first 10 prime numbers: 2, 5, 7,...
Write a program that prints the sum of its command-line arguments (assuming they are numbers). For...
Write a program that prints the sum of its command-line arguments (assuming they are numbers). For example, java Adder 3 2.5 -4.1 should print The sum is 1.4
Question1; Write a c++ program that prints all natural numbers between 10(included) to 100(included) by the...
Question1; Write a c++ program that prints all natural numbers between 10(included) to 100(included) by the while loop. question2: Write a C++ program that prints all numbers between 10 to 1000 that are divisible by 5
Write a program that prints out all numbers, less than or equal to 10,000,000, that are...
Write a program that prints out all numbers, less than or equal to 10,000,000, that are evenly divisible by all numbers between 5 and 15 (inclusive). Do not use any libraries besides stdio.h. Need it in 10 minutes, please.
Write a C++ program that prints out all of the command line arguments passed to the...
Write a C++ program that prints out all of the command line arguments passed to the program. Each command line argument should be separated from the others with a comma and a space. If a command line argument ends in a comma, then another comma should NOT be added
Python Write a program that takes a text filename as command line argument, and prints number...
Python Write a program that takes a text filename as command line argument, and prints number of times each letter occurred in this file.
Write a program in C++ that prints out the even numbers between 1 and 21 using...
Write a program in C++ that prints out the even numbers between 1 and 21 using WHILE loop. Also, find the sum AND product of these numbers and display the resulting sum and product.
Write a program that echoes the input one word per line. Remove all punctuation and all...
Write a program that echoes the input one word per line. Remove all punctuation and all blank lines. Code must be written in C. Not c++ or c#. Input: Use the following Ogden Nash poem to test your program. The Parsnip The parsnip, children, I repeat, Is simply an anemic beet. Some people call the parsnip edible; Myself, I find this claim incredible Note: There are multiple blank lines before and after the title. There may be multiple blank spaces...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT