Python Programming: An Introduction to Computer Science
3rd Edition
ISBN: 9781590282779
Author: John Zelle
Publisher: Franklin Beedle & Associates
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 3, Problem 6PE
Program Plan Intro
Slope of a line
- Define the main function.
- Get the values of “x1”, “x2”, “y1”, and “y2” from the user.
- Calculate slope of the line and store it in a variable “slope”.
- Print the value of “slope”.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a Phyton program that computes the duration of a projectile’s flight and its height above the ground when it reaches the target. As part of your solution, you should display instructions to the program user.
Relevant formula:
time = distancevelocity xcos (θ)
height = velocity xsin x time- g x time22
use the following variables:
g = gravitational constant = 32.17
= angle of elevation in radian
v = velocity or the projectile velocity (ft/sec)
d= distance to target
t = time of flight in seconds.
h = height at impact
Try your program on these data sets.
Two points in a plane are specified using the coordinates (x1,y1) and(x2,y2). Write a program that calculates the slope of a line through two(non-vertical) points entered by the user.y2 - y1 slope=x 2 1
Body Mass Index (BMI) is a measure of health on weight. It can be calculated by taking your weight in kilograms and dividing by the square of your height in meters.
Write a program which prompts the user to enter the weight in kgs (integer value) and height in feet and inches (both integers) and then calculates the BMI of the person. Your
program first need to convert inches to meters (i.e. inches * 0.0254) and then use the following formula to calculate BMI:
weight kilogram / (height_meter)^2
Your program displays the BMI value in two decimal places and the corresponding status as shown in the examples below. Note that one inch is 0.0254 meters and 1 foot is 12
inches.
For example:
Input Result
62
5
10
89
6
0
45
BMI
BMI < 18.5
18.5 s BMI < 25.0
25.0 ≤ BMI < 30.0
30.0 ≤ BMI
7
82
5
Interpretation
Underweight
Normal
Overweight
Obese
2
Enter weight (kg):
Enter height (feet):
Enter height (inches):
BMI is 19.61, Normal
Enter weight (kg):
Enter height (feet):
Enter height (inches):
BMI is…
Chapter 3 Solutions
Python Programming: An Introduction to Computer Science
Ch. 3 - Prob. 1TFCh. 3 - Prob. 2TFCh. 3 - Prob. 3TFCh. 3 - Prob. 4TFCh. 3 - Prob. 5TFCh. 3 - Prob. 6TFCh. 3 - Prob. 7TFCh. 3 - Prob. 8TFCh. 3 - Prob. 9TFCh. 3 - Prob. 10TF
Ch. 3 - Prob. 1MCCh. 3 - Prob. 2MCCh. 3 - Prob. 3MCCh. 3 - Prob. 4MCCh. 3 - Prob. 5MCCh. 3 - Prob. 6MCCh. 3 - Prob. 7MCCh. 3 - Prob. 8MCCh. 3 - Prob. 9MCCh. 3 - Prob. 10MCCh. 3 - Prob. 1DCh. 3 - Prob. 3DCh. 3 - Prob. 4DCh. 3 - Prob. 6DCh. 3 - Prob. 1PECh. 3 - Prob. 2PECh. 3 - Prob. 3PECh. 3 - Prob. 4PECh. 3 - Prob. 5PECh. 3 - Prob. 6PECh. 3 - Prob. 7PECh. 3 - Prob. 8PECh. 3 - Prob. 9PECh. 3 - Prob. 10PECh. 3 - Prob. 11PECh. 3 - Prob. 12PECh. 3 - Prob. 13PECh. 3 - Prob. 14PECh. 3 - Prob. 15PECh. 3 - Prob. 16PECh. 3 - Prob. 17PE
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
- A-Write a program to compute the drag force F, (in Newton) When a body swims through fluid, the drag force is given by 1 F₁ =pV²ACD Take: p= 1000 kg/m3 is the density of fluid, V 1.25 (m/s) is the swimming speed, A=0.25 m² is the frontal area of the body, Cp=0.09 is the coefficient of drag. Matlaparrow_forwardDevelop a program to calculate the height of a building. To measure how tall the building is you go to the top floor and let a stone fall to the ground, while measuring the time it takes to reach the ground. To increase the precision of the calculations the experiment is conducted a number of times. The user should input how many times he conducted the test and input the time (t) for each test. Calculate the height h given the equation h= ½ (g * t ³) where t is the time and g= 9.81 m/s (this is a constant). The program should print out the height expressed in meters.arrow_forwardquadratic.py by using "sys.argv" ● Create a program, quadratic.py, that takes in three arguments that represent the a, b, and c values in the quadratic formula. The values should be to two decimal places. You do not need to account for imaginary values. Then print out both roots in the form: “The solutions are x and y” Where x and y correspond to the positive and negative roots, respectively.arrow_forward
- When Jacob Steinberg began his trip from California to Vermont, he filled his car’s tank with gas and reset its trip meter to 0. After traveling 324 miles, Jacob stopped at a gas station to refuel; the gas tank required 17 gallons. Jacob wants a program that calculates and displays his car’s gas mileage at any time during the trip. The gas mileage is the number of miles his car can be driven per gallon of gas. Desk-check your solution’s algorithm using 324 as the number of miles driven and 17 as the number of gallons used; then desk-check it using 280 and 15.arrow_forwardAssume letters A/a, E/e, I/i, O/o, and U/u as the vowels. Write a program that prompts the user to enter a letter and check whether the letter is a vowel or consonant.arrow_forwardA. Sum of Others: Write a program called sum_of_others.py Given three numbers x, y, , determine if one of them is the sum of the other two. If so, print the equation, otherwise print "None found". For example, if x = 2, y = 1, and z = 3, print "z = x+y". If there are multiple possibilities (such as all values equal to 0) favor the solutions in this order: "x=y+z", "y= X+2", and "z = x +y".arrow_forward
- Body Mass Index (BM) is a measure of health on weight. It can be calculated by taking your weight in kilograms and dividing by the square of your height in meters. Interpretation Underweight Write a program which prompts the user to enter the weight in kgs (integer value) and height in feet and inches (both integers) and then calculates the BMI of the person. Your program first need to convert inches to meters (L.e. inches 0.0254) and then use the following formula to calculate BM weight kilogram/ (height meter) 2 5 Your program displays the BMI value in two decimal places and the corresponding status as shown in the examples below. Note that one inch is 0.0254 meters and 1 foot is 12 inches. For example: Input Result 62 10 89 6 45 BMI BMI < 18.5 185 BMI <25.0 25.0 < BMI <30.0 30.0 s BMI 5 7 Normal Overweight Obese 82 2 Enter weight (kg): Enter height (feet): Enter height (inches): BMI is 19.61, Normal Enter weight (kg): Enter height (feet): Enter height (inches): BMI is 26.61,…arrow_forwardBody mass index (BMI) is a measure of health based on weight. It can be calculated by taking your weight in kilograms and dividing it by the square of your height in meters. Write a program that prompts the user to enter a weight in pounds and height in inches and displays the BMI. Note that one pound is 0.45359237 kilograms and one inch is 0.0254 meters.arrow_forwardQ3: The volume of a circular cylinder V=Ttr?h, write a program to compute the volume if r=8m and h=15m and then create another cylinder have a size larger than the first by 20%, but having the same height as the first, how much the radius should bearrow_forward
- Q4: Write a program to calculate (Z) from the following equation z=A.T A== M F=1.58 T=53 Sec. M 20 40 60 80 100arrow_forwardNewton’s law states that the force, F, between two bodies of masses M1 and M2 is given by: F = k in which k is the gravitational constant and d is the distance between the bodies. The value of k is approximately 6.67 x 10-8 dyn. cm2/g2. Write the algorithm and a program that prompts the user to input the masses of the bodies and the distance between the bodies. The program then outputs the force between the bodies.arrow_forwardProgram by using C # C sharp My student number :1910206534arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
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