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
Concept explainers
Question
Chapter 2, Problem 10PE
Program Plan Intro
Convert kilometers to miles
Program Plan:
- Declare a main function. Inside the main function,
- Print the statement
- Get the kilometers from the user
- Calculate the distance in miles.
- Print the distance in miles.
- Call the main function.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a program that converts distances
measured in kilometers to miles. One
kilometer isapproximately 0.62 miles
An instructor gives a series of exams during the semester in her math class. At the end of
the semester she drops each student's lowest test score before averaging the scores. She has
asked you to design a program that will read a student's test scores as input and calculate
the average with the lowest score dropped. Here is the algorithm that you developed:
Get the student's test scores.
Calculate the total of the scores.
Find the lowest score.
Subtract the lowest score from the total. This gives the adjusted total.
Divide the adjusted total by 1 less than the number of test scores. This is the adjusted average.
Display the average.
The test scores are in a text file named scores.txt and contains the following:
Mickey, 71.0, 42.0, 83.0
Donald, 94.0, 73.0, 72.0, 81.0
Minnie, 95.0, 85.0, 45.0, 55.0, 65.0
A sample run is as follows:
Enter a file containing floating point numbers: scores.txt
Test scores for Mickey: ['71.0', '42.0', '83.0']
Removed the lowest score of 42.0 for Mickey
The…
Write a program that reads from the user a character ('q' or 'c').
If the character is 'c', the program reads from the user the radius rof a circle and prints its area.
• If the user enters 'q', the program asks the user to enter the length and width of a quadrilateral. We
assume the quadrilateral is either a square or rectangle. You should print if the quadrilateral is square
or rectangle.
• Otherwise, it prints "Wrong character"
PS: Use the following formulas:
area of circle=3.14*r
Sample Run1:
Enter a character (q or c): q
Enter the Length and Width: 80 150
|It is a rectangle
Sample Run2:
Enter a character (q or c): q
Enter the Length and Width: 80 80
It is a square
Sample Run3:
Enter a character (q or c): c
Enter the radius: 2
The area of the circle is 12.56
Sample Run4:
Enter a character (q or c): d
Wrong character
Chapter 2 Solutions
Python Programming: An Introduction to Computer Science, 3rd Ed.
Ch. 2 - Prob. 1TFCh. 2 - Prob. 2TFCh. 2 - Prob. 3TFCh. 2 - Prob. 4TFCh. 2 - Prob. 5TFCh. 2 - Prob. 6TFCh. 2 - Prob. 7TFCh. 2 - Prob. 8TFCh. 2 - Prob. 9TFCh. 2 - Prob. 10TF
Ch. 2 - Prob. 1MCCh. 2 - Prob. 2MCCh. 2 - Prob. 3MCCh. 2 - Prob. 4MCCh. 2 - Prob. 5MCCh. 2 - Prob. 6MCCh. 2 - Prob. 7MCCh. 2 - Prob. 8MCCh. 2 - Prob. 9MCCh. 2 - Prob. 10MCCh. 2 - Prob. 1DCh. 2 - Prob. 3DCh. 2 - Prob. 4DCh. 2 - Prob. 5DCh. 2 - Prob. 6DCh. 2 - Prob. 7DCh. 2 - Prob. 1PECh. 2 - Prob. 2PECh. 2 - Prob. 3PECh. 2 - Prob. 4PECh. 2 - Prob. 5PECh. 2 - Prob. 6PECh. 2 - Prob. 7PECh. 2 - Prob. 8PECh. 2 - Prob. 9PECh. 2 - Prob. 10PECh. 2 - Prob. 11PECh. 2 - Prob. 12PE
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
- Write a program that reads the employee's name and base salary and then calculates the tax and net amount Salary where: Net salary = Basic salary If the basic salary is less than 500 (no tax) Net salary = basic salary - tax value So that the tax amount is 5% of the basic salary Then it prints the employee's name and net salary %3D 2:40 PM /arrow_forwardWrite a program in python Suppose a right triangle is placed in a plane as shown below. The right-angle point is at (0, 0), and the other two points are at (200, 0), and (0, 100). Write a program that prompts the user to enter a point with x- and y-coordinates and determines whether the point is inside the triangle. Sample runs of the program are given below: Enter a point's x- and y-coordinates: 100.5 25.5 The point is in the triangle Enter a point's x- and y-coordinates: 100.5 50.5 The point is not in the trianglearrow_forwardWrite a program that calculates the number of hours, minutes, and seconds in N seconds.Example: In 3601 it is equal to 1 hour 0 minutes 1 secondarrow_forward
- Write a program that reads two integers, a and b, from the user. Where a is equal to 17 and b is equal to 4. The program should compute and display the following: i. Sum of a and b. ii. Difference when b is subtracted from a. ii. Result of a. iv. Remainder when a is divided by b.arrow_forwardWrite a program that reads from the user a character (*q' or 'c'). If the character is 'c', the program reads from the user the radius r of a circle and prints its area. If the user enters 'q', the program asks the user to enter the length and width of a quadrilateral. We assume the quadrilateral is either a square or rectangle. You should print if the quadrilateral is square or rectangle. Otherwise, it prints "Wrong character" PS: Use the following formulas : area of circle=3.14*r? Iarrow_forwardWrite a program that will read value of the radius to compute the Area and Perimeter of a Circle. Use the formulas below: area = Pi * radius * radius perimeter = 2 *Pi * radius Where value of Pi is 22/7 = 3.14 Display the computed area and perimeter.arrow_forward
- Write a program that reads 6 integers and displays the largest and the smallest amongst those integers.arrow_forwardWrite a program that calculates the potential energy of 3 charges q1 = 1, q2 = 2, q3 = 3 located at points (1,2, 3), (3, –4, –5), and (-4, 2, –6) respectively. The units are coulombs for charge and meters for coordinates. The energy is given by the expression 9293 9193 9142 + T12 U = k r23 T13 where is the distance between the charges q; and q;, and k = 9 × 10º in SI units. Tij Your program should print the result on the screen.arrow_forwardWrite a program that first reads the value n, which is the number of numbers to average. It should then read the n positive (float) numbers, average them, and display the average. ENTRYAn integer n and then the n floating numbers EXIT The average of the n numbers read. Example of program execution: Input 3 Entry 2.5 Entry 3.8 Entry 4.6 Output3.633333333333333arrow_forward
- Write a program that calculates the equivalent resistance of a circuit. n electrical resistors with resistance values R1, R2,.., Rn are said to be connected in parallel if the same voltage is applied across each. Their equivalent resistance Reg is related to the values R1, R2, ..., Rn by: 1 1 1 1 + +...+ R R R, R. "eq Write a program that prompts the user to enter the resistance of n resistors. The user should be prompted continuously by using a while loop until a zero or negative value is entered (the program should count the number of resistors n entered by the user and store the values in an array). Use another separate loop to print the resistance values entered by the user and the equivalent resistance Reg. Test your program with R1= 1 kn, R2= 2 kn, R3= 4 kQ and R4= 8 kQ.arrow_forwardOne acre of land is equivalent to 43,560 square feet. Write a program that calculates the number of acres in a tract of land with 389,767 square feet.arrow_forward4. Write a Phyton program that computes the speed of sound (a) in air of a given temperature T (°F ). Use the formula 5T+2297 2457 a = 10861arrow_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
Constants, Variables, Data types, Keywords in C Programming Language Tutorial; Author: LearningLad;https://www.youtube.com/watch?v=d7tdL-ZEWdE;License: Standard YouTube License, CC-BY