Python Programming: An Introduction to Computer Science, 3rd Ed.
3rd Edition
ISBN: 9781590282755
Author: John Zelle
Publisher: Franklin, Beedle & Associates
expand_more
expand_more
format_list_bulleted
Question
Chapter 5, Problem 11PE
Program Plan Intro
Program to print a formatted table
Program plan
- In the function “main()”,
- Define the variables “x” and “y” and get the inputs from the user.
- Define variable “z” and is printed as input.
- Execute “for” loop and if variable“i” is in the range of “10”,
- Then define the variables “x” and “y”.
- Print the formatted table.
- Call the function “main()”.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Python
For this lab, you will use a tuple to represent a student record. A student record consists of the student’s name, year, and GPA. For example, (“John”, “Senior”, 3.7) is a record for John who is a senior with a 3.7 GPA.
You will write a program that prompts the user for the number of records to enter. Then it reads input from the user for each record. Remember that each record consists of a student’s name, year, and GPA. It then prints the record of each student as shown below.
Functions: You will write the following functions:
read_records(n)
Read n number of records and return a list of records.
print_records(records)
Takes in a list of records and print each one.
main()
Prompts the user for the number of records to read, get a list of records from the user, and print the records.
Optional: print the average GPA of the students.
Sample run:
How many students record to enter: 2
Enter student's name: John
Enter student's year: junior
Enter…
Write a program that simulates picking a card from a deck of 52 cards. Your program should display the rank (Ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King) and suit (Clubs, Diamonds, Hearts, Spades) of the card.
Develop a solution that will calculate the average temperature, given a set of temperatures. The number of temperatures may differ from time to time. (Use a trip values to stop the processing of the loop.) Test the solution with the following 10 temperatures.
78 90
85 80
87 83
75 90
86 70
Chapter 5 Solutions
Python Programming: An Introduction to Computer Science, 3rd Ed.
Ch. 5 - Prob. 1TFCh. 5 - Prob. 2TFCh. 5 - Prob. 3TFCh. 5 - Prob. 4TFCh. 5 - Prob. 5TFCh. 5 - Prob. 6TFCh. 5 - Prob. 7TFCh. 5 - Prob. 8TFCh. 5 - Prob. 9TFCh. 5 - Prob. 10TF
Ch. 5 - Prob. 1MCCh. 5 - Prob. 2MCCh. 5 - Prob. 3MCCh. 5 - Prob. 4MCCh. 5 - Prob. 5MCCh. 5 - Prob. 6MCCh. 5 - Prob. 7MCCh. 5 - Prob. 8MCCh. 5 - Prob. 9MCCh. 5 - Prob. 10MCCh. 5 - Prob. 1DCh. 5 - Prob. 2DCh. 5 - Prob. 3DCh. 5 - Prob. 4DCh. 5 - Prob. 5DCh. 5 - Prob. 1PECh. 5 - Prob. 2PECh. 5 - Prob. 3PECh. 5 - Prob. 4PECh. 5 - Prob. 5PECh. 5 - Prob. 6PECh. 5 - Prob. 7PECh. 5 - Prob. 8PECh. 5 - Prob. 9PECh. 5 - Prob. 10PECh. 5 - Prob. 11PECh. 5 - Prob. 12PECh. 5 - Prob. 13PECh. 5 - Prob. 14PECh. 5 - Prob. 15PECh. 5 - Prob. 16PE
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Print numbers 0, 1, 2, ..., userNum as shown, with each number indented by that number of spaces. For each printed line, print the leading spaces, then the number, and then a newline. Hint: Use i and j as loop variables (initialize i and j explicitly). Note: Avoid any other spaces like spaces after the printed number. Ex: userNum = 3 prints: 0 1 2 3arrow_forwardUsing Dart. Create a program that will play the “cows and bulls” game with the user. The game works like this: Randomly generate a 4-digit number. Ask the user to guess a 4-digit number. For every digit the user guessed correctly in the correct place, they have a “cow”. For every digit the user guessed correctly in the wrong place is a “bull.” Every time the user makes a guess, tell them how many “cows” and “bulls” they have. Once the user guesses the correct number, the game is over. Keep track of the number of guesses the user makes throughout the game and tell the user at the end.arrow_forwardWrite a program that asks the user to enter an integer number and checks whether the number is prime or not. Hint: A prime number (2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37 . . . ) is a natural number greater than 1 that has no positive divisors other than 1 and itself. To check if a number N is prime, divide it in a loop from 2 to N-1 for remainder. If remainder is never 0, then N is prime. For example, 23 and 47 are prime, but 12 and 27 are not.arrow_forward
- Write a program called StudentTable that prints the below table. Use only print() or printf(). DO NOT use println(). ////////////////////\\\\\\\\\\\\\\\\\\\\=============Student Points=============\\\\\\\\\\\\\\\\\\\\////////////////////Name Lab Bonus Total ---- --- ----- -----Joe C 7 50.5William B 8 58.2Mary Sue G 10 49.91) Use \\ to print a single \2) Use \n to go to next line3) Use left justify %– each for Name, Lab, Bonus, Total4) Use width size of 10 (%10) each for Name, Lab, Bonus, Total5) Use %s for String (Joe, William, Mary Sue), %c for char (C, B, G), %d for int (7, 8, 10), %f for double (50.5, 58.2, 49.9)arrow_forwardA very known application in natural language processing is to extract information from a given text. In this lab, you will be able to extract some emotions (Sad and Happy) from a given string and calculate the score of each emotion. You will be given below the words that express sadness, anger, and happiness. For each word, you will be given weight as well, so that when you are calculating for example the score for sadness in the text (string), you can use this formula:arrow_forwardMake Camel Case. Create a program that reads a multi-word phrase, and prints the Camel Case equivalent. For example, for input “total account balance” the program shall output “totalAccountBalance”.Notice that the first word is in lowercase (even if it contains uppercase letters). The rest of the words, only their initials are capitalized.arrow_forward
- Write a program that prompts the user to enter a sequence of numbers until a -999 is entered. It will print the numbers the user entered, five number in a row,with a before the first number and after the last number in each row. For example, Enter a number (-999 to stop): 23Enter a number (-999 to stop): 15Enter a number (-999 to stop): 1Enter a number (-999 to stop): 7Enter a number (-999 to stop): 9Enter a number (-999 to stop): 21Enter a number (-999 to stop): 17Enter a number (-999 to stop): 33Enter a number (-999 to stop): -999[23 15.17 9] [21 17 33]arrow_forwardDevelop a solution that will calculate the average temperature, given a set of temperatures. The number of temperatures may vary from time to time. (Use a trip value (counter) to stop the processing of the loop.) Test the solution with the following 10 temperatures78, 90, 85, 80, 87, 83, 75, 90, 86 and 70arrow_forwardIn Python, write an improved version of the chaos.py program that allows a user to input 2 initial values and the number of iterations and then prints a nicely formatted table showing how the values change over time. for example, if the starting values were .25 and .26 with 10 iterations, the table might look the attached table. Except write it to a file and the another program and print it from the file.arrow_forward
- Coupon collector is a classic statistic problem with many practical applications. The problem is to pick objects from a set of objects repeatedly and determine how many picks are needed for all the objects to be picked at least once. A variation of the problem is to pick cards from a shuffled deck of 52 cards repeatedly and find out how many picks are needed before you see one of each suit. Assume a picked card is placed back in the deck before picking another. Write a program to simulate the number of picks needed to get four cards from each suit and display the four cards picked (it is possible that a card may be picked twice).arrow_forwardjava Use a loop to track the growth of the Utopian Tree. The tree grows exactly 1 cm for the first three years, and then afterwards it grows by 2 cm every year. Show the growth of the tree each year up to year 10. See the example flow below. Use the format: year x - growth x cm tree size: x cm where the 'x' values are different values of year, the growth amount, and the total tree size up to that yeararrow_forwardJogging burns 3.9 calories per minute. Write a python program that uses a loop to display (in a table format) the number of calories burned after 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55 and 60 minutes.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Java random numbers; Author: Bro code;https://www.youtube.com/watch?v=VMZLPl16P5c;License: Standard YouTube License, CC-BY