Concept explainers
Distance Traveled
The distance a vehicle travels can be calculated as follows:
distance = speed x time
For example, if a train travels 40 miles per hour for three hours, the distance traveled is 120 miles. Write a
What is the speed of the vehicle in mph? 40 Enter
How many hours has it travelled? 3 Enter
Hour | Distance Traveled |
1 | 40 |
2 | 80 |
3 | 120 |
Learn your wayIncludes step-by-step video
Chapter 4 Solutions
Starting Out with Python (4th Edition)
Additional Engineering Textbook Solutions
Computer Systems: A Programmer's Perspective (3rd Edition)
Concepts Of Programming Languages
Starting Out With Visual Basic (7th Edition)
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Database Concepts (8th Edition)
Starting out with Visual C# (4th Edition)
- Write a program that uses nested loops to collect data and calculate the average rainfall over a period of years. The program should first ask the user for the number of years. The outer loop will iterate once for each year. The inner loop will iterate 12 times, once for each month. Each iteration of the inner loop will ask the user for the inches of rainfall for that month. After all iterations, the program should display the number of months, the total inches of rainfall, and the average rainfall per month for the entire period. Add additional loops to validate the input: Do not accept a number less than 1 for the number of years. Continue to prompt the user for a number until a valid number is entered. Do not accept negative numbers for the monthly rainfall. Continue to prompt the user for a number until a valid number is enteredarrow_forwarda. A bowling team consists of five players. Each player bowls three games. Write a program that uses a nested loop to enter each player's individual scores and then computes and displays the average score for each bowler. Assume that each bowler has the following scores. Use two different loop structures for outer loop and inner loop. For example, if you use "for" as the outer loop structure, the inner loop should be "while" or "do.... while". 1st bowler: 286 2nd bowler: 212 3rd bowler: 252 232 4th bowler: 192 201 265 215 216 235 5th bowler: 186 252 186 236 272 b. Modify the program written for Exercise 3a to calculate and display the average team score. (Hint: Use a second variable to store the total of all the players' scores.)arrow_forwardDesign a program that uses nested loops to collect data and calculate the average rainfall over a period of years. The program should first ask for the number of years. The outer loop will iterate once for each year. The inner loop will iterate twelve times, once for each month. Each iteration of the inner loop will ask the user for the inches of rainfall for that month. After all iterations, the program should display the number of months, the total inches of rainfall, and the average rainfall per month for the entire period. Modularize the program. Present clear formatted code with comments. I need this coded in pseudocode, please.arrow_forward
- Overview This program will prompt a user for a start and a limit, it will then while-loop through, doubling the iterator each pass, until the limit is reached. Expected Output Example 1 Enter the start of the loop: Enter the limit of the loop: 25 The current value is 3 The current value is 6 The current value is 12 The current value is 24 The last value of current that was less than 25 was 24 Example 2 Enter the start of the loop: 25 Enter the limit of the loop: 102 The current value is 25 The current value is 50 The current value is 100 The last value of current that was less than 102 was 100 Specifications • You should submit a single file called M5A2.py • It should follow the submission standards outlined here: Submission Standards Your program populate an integer named start using input • Your program populate an integer named limit using input Your program must use an iterator named current Your program must move through the values using a while-loop Tips and Tricks That last…arrow_forwardWrite a program that displays a weekly payroll report. A loop in the program should ask the user for the employee number, gross pay, state tax, federal tax, and FICA withholdings. The loop will terminate when 0 is entered for the employee number. After the date is entered, the program should display totals for gross pay, state tax, federal tax, FICA withholdings, and net pay.arrow_forwardPython programming Write a program that generates a random number and asks the user to guess what the number is. If the user's guess is higher than the random number, the program should display "Too high, try again." If the user's guess is lower than the random number, the program should display "Too low, try again." The program should use a loop that repeats until the user correctly guesses the random number. TY!arrow_forward
- Programming Problem 1Write a program that has the user input their height in inches and convert it to meters. Print the inches and the converted meters. The program should allow the user to enter as many heights as they want (use a loop for this).arrow_forwardYou want to determine the amount you will save for a down payment on a home in the next 3-7 years. You are opening an account with $750. Each year a contribution of $2400 will be made. Assume that there is a 2.75% compound interest rate paid on the balance at the end of the year. Display the year and the savings amount at the end of each year - beginning with the current year. Write your program using a loop that displays the projected savings for each year. (Try using a function that calculates the end of year interest - pass the balance (previous balance plus investment ($2400)), calculate the interest and return the interest amount))arrow_forwardPython Coding-While Loops (In PyCharm Community edition) Create a while loop that SUMS up ALL the numbers given from an initial number and an ending number. Example would be : Input1 : What is the first number? 0 Input2 : What is the last number? 3 DO NOT SHOW but these are the computations inside the code : 0 + 1 + 2 + 3 = 6 This is the Output : The sum of all the number from 0 to 3, is 6 In the code you are going to use a total variable and add each additional time it runs through the loop to that total. REMEMBER the assignment from the first unit of programming where we used this formula : BUT you are going to create your own method using a while loop to emulate what formula accomplishes WITHOUT using this formula. The user will put in the first number and the last to be SUMMED - you will use the while loop to calculate all of the additions leading to the final number.arrow_forward
- Task 2: Multiples Write a program that asks the user for an integer n, and then prints first 10 multiples of that integer. Use a while/do...while loop. Example: Enter an integer: 2 Output: 2 x 1 = 2 2 x 2 = 4 2 х 3 %3D 6 2 x 4 = 8 2 x 5 = 10 12 2 х6 2 x 7 2 х8 14 16 2 x 9 18 2 x 10 = 20arrow_forwardPython The month of February typically has28 days except when it is a leap year, in which case February has 29 days.Write a program that asks the user to enter a year. The program should then display the number of days in February that year. Use the following criteria to identify leap years: The program shall loop back to ask the user to enter another year. The program shall NOT display the original display message explaining what the program does If the user enters an invalid year, the program willdisplay an error message to the user and prompt for a year If the user enters 0 or hits return for the year, then the program terminatesarrow_forwardPYTHON PROGRAMMING ONLY. Please provide explanation as well. Thank you. Write a while loop that lets a user enter a number less than 10. If the number inputted exceeds 10, print an error and ask for the number again, in which a user may enter the same or a different number. When the user inputs a valid number, the number should be incremented by 5, and the result assigned to a variable named sum. This loop should continue to iterate as long as the sum totals less than 50. When sum exceeds 30, it should print "Almost there..." until it reaches or exceeds 50. Once it does, print out "your final sum is (replace with final sum)". For example, if the sum is currently 45 and the user inputs 4, the program will not enter the loop again since the new sum will be 54 and should then print "your final sum is 45".arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage