Question

In: Computer Science

13) Make a program that receives the sex of people like M or F. At the...

13) Make a program that receives the sex of people like M or F. At the end, show how many
is male and female. However, if the user types a letter
different from M or F, the program should ask him to type again. Create a form of
end the program and display the result.

14) Create a program that draws a number between 1 and 10. Right after, the program must ask
for the user to guess the number drawn. When the user is correct, display on the screen according to
times he tried. Obs: SEARCH FOR RANDOM NUMBERS IN PYTHON

15) Receive two numbers from the user and display the menu:
type it
1-Display a sum
2-Display a subtraction
3-Display multiplication
4-Display the division
5-Exit
The user chooses an option, the result of the operation appears on the screen and the menu is to apply
again, until the user chooses an option 5.

16) Ask if the user wants to enter a temperature in Celsius and convert to
Fahrenheit, or from Fahrenheit to Celsius. Receive the value, convert, display the result and
question whether he wants to do another calculation or leave the program. Use as formulas:
(F - 32) × 5/9 = C
(C × 9/5) + 32 = F

17) Receive and check if the user's network number is triangular or not. Repeat one
operation until the user enters a number equal to 0. A triangular number is equal to
sum of first numbers, examples:
6 is a triangular number, because 6 = 1 + 2 + 3
10 is a triangular number, because 10 = 1 + 2 + 3 + 4
15 is a triangular number, because 15 = 1 + 2 + 3 + 4 + 5

18) Given integers n, i and j, all greater than zero, print in ascending order
the natural first n which are multiples of i or j and or both.
For example, for n = 6, i = 2 and j = 3 the output should be: 0 2 3 4 6 8

19) In a gymnastics competition, each athlete receives votes from seven jurors. The best and the
worst score are eliminated. The athlete's score is the average of the remaining votes. You must
make a program that receives the name of the gymnast and the scores of the seven jurors achieved by the
athlete in his presentation. Your program should display an average, as described above
(remove the best and worst jump and then average with the remaining grades). As notes don't
are reported in order. An example of the program output should be as the example
below:
Data entered by the user:
Athlete name: Rone Ilídio
Score: 9.9
Score: 7.5
Score: 9.5
Score: 8.5
Score: 9.0
Score: 8.5
Score: 9.7
Result that should be applied:
Athlete: Rone Ilídio
Best grade: 9.9
Worst grade: 7.5
Average: 9.04

Solutions

Expert Solution

Problem 13:

male=0 #to store count of male
female=0 #to store count of female
for i in range(5): #say user needs to enter input for 5 times
    sex=input("Enter M for Male or F for Female\n")
    while(sex!='M' and sex!='F'):
        sex=input("Enter M for Male or F for Female\n") #input till user enter M or F
    if sex=='M':
        male+=1
    elif sex=='F':
        female+=1
print("Number of male: ",male)
print("Number of female: ",female)

Output and code screenshot:

Problem 14:

import random
random_number=random.randint(1,10)
guesses=0
flag=True #set flag to true
while flag:
    number=int(input("Enter the number: "))
    if number==random_number: 
        guesses+=1
        flag=False #set flag to false if number is correct so that block will end
    else:
        print("Sorry!! Try again!!") #else ask user to enter it again
        guesses+=1 #count the guesses every time
print("Number of tries to guess the number",guesses) #print the number of tries to guess the number

Output and code screenshot:

Problem 15:

flag=True #set flag to true
num1=int(input("Enter number 1: ")) #input 2 numbers
num2=int(input("Enter number 2: "))
while flag:
    print("1-Display the sum\n2-Display the subtraction\n3-Display the multiplication\n4-Display the division\n5-Exit\n") #display menu
    choice=int(input("Enter your choice: ")) #input choice
    #calculate based on choices
    if choice==1:
        print("Sum: ",num1+num2)
    elif choice==2:
        print("Subtraction: ",num1-num2)
    elif choice==3:
        print("Multiplication: ",num1*num2)
    elif choice==4:
        print("Division: ",num1/num2)
    elif choice==5: #if choice is 5 then set flag to false. This will exit the block
        flag=False 

Output and code screenshot:

Problem 16:

flag=True #Set flag to true
while flag:
    scale=input("How you want to calculate the temperature? Enter C for Celsius or F for Fahrenheit: ") #input C or F
    while(scale!='F' and scale!='C'): #if scale is not C or F ask user to input again
        scale=input("How you want to calculate the temperature? Enter C for Celsius or F for Fahrenheit: ")
    temp=float(input("Enter the temperature: ")) #input temperature
    #caculate based on scale
    if scale=='C':
        temp=(temp*(9/5))+32
        print("Temperature is %.2f F"%(temp))
    elif scale=='F':
        temp=(temp-32)*(5/9)
        print("Temperature is %.2f C"%(temp))
    option=int(input("enter 1 to Try again or 0 to exit: ")) #input option to continue or exit
    while(option!=0 and option!=1):
         option=int(input("enter 1 to Try again or 0 to exit: "))
    if option==0:
        flag=False
    
        

Output and code screenshot:

Dear, we were instructed to solve a max of 4 questions. So please upload the remaining questions separately.

#Please don't forget to upvote if you find the solution helpful. Feel free to ask doubts if any, in the comments section. Thank you.


Related Solutions

1. Make the flow diagram and the C ++ program that receives three integer values ​​R,...
1. Make the flow diagram and the C ++ program that receives three integer values ​​R, T and Q, determine if they satisfy the expression below, and if so, show the corresponding values ​​of R, T and Q. R'- T '+ 4 * Q? <820 2. Construct a flow chart and the corresponding program in C which, when receiving Y as data, calculates the result of the following function and prints the values ​​of X and Y.
I got this homework, to make an appointment program. it says like this: Write a superclass...
I got this homework, to make an appointment program. it says like this: Write a superclass Appointment and subclasses OneTime, Daily, and Monthly. An Appointment has a description (for example “see the dentist”) and a date. Write a method occursOn(int year, int month, int day) that checks whether the appointment occurs on that date. For example, for a monthly appointment, you must check whether the day of the month matches. You are provided with a Junit test AppointmentTest .java. Run...
Student Sex math physic chem 401 F 83 53 60 402 M 66 58 61 403...
Student Sex math physic chem 401 F 83 53 60 402 M 66 58 61 403 F 78 49 62 404 M 71 66 60 405 F 77 43 46 406 M 71 49 50 407 F 80 54 59 408 M 70 60 58 409 F 82 54 56 410 M 70 52 57 411 F 80 48 52 412 M 70 53 47 413 F 80 48 47 414 M 68 50 58 415 F 82 62 60...
Student Sex math physic chem 401 F 83 53 60 402 M 66 58 61 403...
Student Sex math physic chem 401 F 83 53 60 402 M 66 58 61 403 F 78 49 62 404 M 71 66 60 405 F 77 43 46 406 M 71 49 50 407 F 80 54 59 408 M 70 60 58 409 F 82 54 56 410 M 70 52 57 411 F 80 48 52 412 M 70 53 47 413 F 80 48 47 414 M 68 50 58 415 F 82 62 60...
I would like to know if the sex of a math student is a statistically significant...
I would like to know if the sex of a math student is a statistically significant factor in predicting average math exam scores. The following lists are exam scores for a math exam, separated by sex. male 89 33 104 48 90 80 98 32 98 55 75 74 73 90 105 47 48 67 99 103 63 female 99 80 81 88 94 83 70 42 78 75 Perform a hypothesis test to determine whether the sex of a...
Make an A Make a B Make a C Make a D Make an F Sophomores...
Make an A Make a B Make a C Make a D Make an F Sophomores .058 .101 .142 .092 .047 Juniors .055 .082 .102 .071 .030 Seniors .014 .023 .080 .063 .040 (a) What is the probability that a randomly selected student in Dr. Alan  Math course is a Sophomore? (b) What is the probability that a randomly selected student will make a D in Dr. Alan  Math course? (c) Given that a particular student made a B or better in...
I would like to make 3.8 M of Perchloric acid and, i have no idea how...
I would like to make 3.8 M of Perchloric acid and, i have no idea how to do it since it is not my field of study. But have to make 3.8 M of Perchloric acid because we need to make sampling fluid with it. Sampling fluid contains 0.11~0.13 grams of 2,4-DNPH+1L of Acetonitrile+0.15 mL of 3.8 M Perchloric acid. The Perchloric acid that i have right now is 70%, 99.999% trace metals basis, Cas:7601-90-3 HCIO4, MW:100.46 g/mol, in a...
WG G 1 M 2 M 7 F 4 M 12 F 2 M 1 M...
WG G 1 M 2 M 7 F 4 M 12 F 2 M 1 M 10 F 1 M 2 M 3 M 1 M 1 M 2 M 1 M Assume that : The first column is the weight gain of the people in the quarantine in the first week in kilogram (WG) .    The second column is describing the gender whether it was male or female (G) . Q: Is there any statistical evidence that the...
why people like to be an entrepreneur ?
why people like to be an entrepreneur ?
Let function F(n, m) outputs n if m = 0 and F(n, m − 1) +...
Let function F(n, m) outputs n if m = 0 and F(n, m − 1) + 1 otherwise. 1. Evaluate F(10, 6). 2. Write a recursion of the running time and solve it . 3. What does F(n, m) compute? Express it in terms of n and m.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT