I'm quite into games now, so how about we play In or Out! When a given number is even, the team scores so we shall print "In", but if it's not an even number, then we print "Out". Simple, right?
Give example of chained conditional
1. Time measurement using song duration
Consider that Alice is cycling from point A to point B. During the cycling, Alice is listening to songs in her music player.
Given the following inputs:
1. The distance between A and B in metres
2. The speed at which Alice is traveling in metres per second
3. Duration of each song in her playlist in the
following format: mm:ss
the program should:
• Print the number of the song that Alice is listening when the cycling is completed from A to B
· Print Invalid input if any of the constraints mentioned in the constraints section is violated
Example 1
Consider the following inputs:
2000
5
Now consider the following list of songs:
05:30
02:04
Describe the difference between a chained conditional and a nested conditional. Give your own example of each. Do not copy examples from the textbook.
Deeply nested conditionals can become difficult to read. Describe a strategy for avoiding nested conditionals. Give your own example of a nested conditional that can be modified to become a single conditional, and show the equivalent single conditional.
A group of medical students were monitoring the body temperature of a patient daily basis. Students captured 10 temperature readings in Celsius on a particular day.
1. Write an Algorithm to input these ten values and get the average temperature for that day. if the average temperature value is in between 970 Fahrenheit and 990 Fahrenheit then display the message “Your body temperature is normal…”. If it is more than 100.40 Fahrenheit then display the message “You have a fever caused by an infection or illness…”.
2. Convert the above algorithm (written in part (1)) to a Python program to output the desired results
For Apple store services and apps(like games, videos, etc ): you can gain access if you
are15years old or less and your parent has an Apple ID. If you are 16 years old or more
you need to have your own Apple ID.
Write a program that uses short circuit logic to tell someone if they are legal to gain
access to Apple store services. First ask them how old they are, whether they have an
Apple ID or not, and whether their parent has an Apple ID or not.
Write a program that determines whether you can run for president. To run for president
the constitution states: No Person except a natural born Citizen, or a Citizen of the South
Africa(SA), at the time of the Adoption of this Constitution, shall be eligible to the Office
of President; neither shall any Person be eligible to that Office who shall not have
attained to the Age of thirty five Years, and been fourteen Years a Resident within the
South Africa. Ask three questions of the user and use the guess and check pattern to
determine if they are eligible to run for President.
The sum of the first n positive integers can be computed by the formula
sum(1..n) = 1 + 2 + 3 + 4 + · · · + n = n(n + 1)/2
Write a short Python program that computes the sum of the first 100 positive integers
and prints it to the screen, using format specifiers when printing instead of converting
each item to a string. Use variables to represent the 1, the 100, and the result of the
computation. Your program must compute the 5050 value. You cannot just print the
result to the screen. You must compute it first from the 100. The goal is for the output to
look exactly the same.The output is as shown below:
sum(1..100) = 5050
Write a program to determine if a string S2 is a rotation of anothe string
You've learned in the past lessons on how to use square root functions, right? Then let's take your knowledge to the test. Print out the square root of a given integer with only two decimal places.