Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Use the following code to answer the below questions. (use python) if my var % 2 == 1 : if my var **3 !=

1. Use the following code to answer the below questions. (use python) if my var % 2 == 1 : if my var **3 != 27 : my var = my var +4 #Assignment 1 e l s e : my var /= 1.5 #Assignment 2 e l s e : if my var <= 10 : my var *= 2 #Assignment 3 e l s e : my var == 2 #Assignment 4 print ( my var ) (a) Find four values of my var so each of the four assignment statements will be executed: each value should cause one assignment statement to be executed. (b) Find four ranges of my var values that will cause each of the four assignment statements to be executed. 2. In your own words, describe the difference in logic of the following two sets of code: (a) if Boolean A :

Block X if Boolean B :

Block Y (b) if Boolean A : Block X Elif Boolean B : Block Y 3. When driving in a car and approaching a traffic control light, green means go, yellow means yield, and red means stop. Assuming there is a variable named light color, write a program that prints either the word go, yield, or red depending on the value of light color. Let the user input the value of light color. 4. The table below shows what your resting heart rate should be based on age and athleticism. Write a the program that asks the user their age and desired athleticism goal, and then outputs what their resting heart rate should be. Athleticism Age Above Average Below Average 20 39 47 72 73 93 40 59 46 71 72 94 60 79 45 70 71 97 Your end output should look similar to this Enter your age: 45 Enter your athleticism goal: Below Average Your resting heart rate should be between 7294. 5. Write a program that prompts the user to enter three integers and displays the integers in non- decreasing order. 6. Write a program that prompts the user to enter three integers and displays the integers in non-increasing order. 7. (Game: heads or tails) Write a program that lets the user guess whether the flip of a coin results in heads or tails. The program randomly generates an integer 0 or 1, which represents the head or tail. The program prompts the user to enter a guess and reports whether the guess is correct or incorrect.

8. In Harry Potter, the currency consists of knuts, sickle, and galleon. There are 29 knuts in one sickle and 17 sickles in one galleon. Write a program that will convert some amount of knuts into the fewest amount of coins possible. Only print non-zero values, mean dont print something similar to 0 sickles. For example, Given 32 knuts, output 1 sickle 3 knuts Given 544 knuts, output 1 galleon 4 sickles 18 knuts Given 993 knuts, output 2 galleons 7 knuts. Do not output 2 galleons 0 sickle 7 knuts.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro SQL Server Administration

Authors: Peter Carter

1st Edition

1484207106, 9781484207109

More Books

Students also viewed these Databases questions

Question

Summarize various training methods.

Answered: 1 week ago