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 3PE
Program Plan Intro
Molecular weight
- Define the main function.
- Declare required variables.
- Get the number of hydrogen atoms, carbon atoms and oxygen atoms from the user and store them in the variables “h”, “c”, and “o” respectively.
- Calculate molecular weight and store it in a variable “molecularWeight”.
- Print the value of “molecularWeight”.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
A complex number is a number in the form a+bi, where a and b are real numbers and i is √(-1)
The numbers a and b are known as the real part and imaginary part of the complex number, respectively. You can perform addition, subtraction, multiplication, and division for complex numbers using the following formulas:
a + bi + c + di = (a+c) + (b+d)i (addition)
a + bi − (c + di) = (a−c) + (b−d)i (subtraction)
(a + bi) * (c + di) = (ac−bd) + (bc+ad)i (multiplication)
(a + bi) / (c + di) = (ac+bd) / (c2+d2) + (bc−ad)i / (c2+d2) (division)
You can obtain the Absolute Value for a complex number using the following formula:
|a + bi| = √(a2 + b2)
A Complex number can be interpreted as a point on a plane by identifying the (a,b) values as the coordinates of the point. The absolute value of the complex number corresponds to the distance of the point to the origin, as shown in the example below.
(1) Design a class named Complex for representing complex numbers
Include…
Program by using C #
C sharp
My student number :1910206534
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
- C#arrow_forwardThe Café Noir Coffee Shop wants some market research on its customers. When a customer places an order, a clerk asks for the customer’s zip code and age. The clerk enters that data as well as the number of items the customer orders. The program operates continuously until the clerk enters a 0 for zip code at the end of the day. When the clerk enters an invalid zip code (more than 5 digits) or an invalid age (defined as less than 10 or more than 110), the program reprompts the clerk continuously. When the clerk enters fewer than 1 or more than 12 items, the program reprompts the clerk two more times. If the clerk enters a high value on the third attempt, the program accepts the high value, but if the clerk enters a negative value onthe third attempt, an error message is displayed and the order is not counted. At the end of the program, display a count of the number of items ordered by customers from the same zip code as the coffee shop (54984), and a count from other zip codes. Also…arrow_forwardPYTHON PROGRAMMINGarrow_forward
- A complex number is a number in the form a + bi, where a and b are real numbers and i is sqrt( -1). The numbers a and b are known as the real part and imaginary part of the complex number, respectively.You can perform addition, subtraction, multiplication, and division for complex numbers using the following formulas:a + bi + c + di = (a + c) + (b + d)ia + bi - (c + di) = (a - c) + (b - d)i(a + bi) * (c + di) = (ac - bd) + (bc + ad)i(a+bi)/(c+di) = (ac+bd)/(c^2 +d^2) + (bc-ad)i/(c^2 +d^2)You can also obtain the absolute value for a complex number using the following formula:| a + bi | = sqrt(a^2 + b^2)(A complex number can be interpreted as a point on a plane by identifying the (a, b) values as the coordinates of the point. The absolute value of the complex number corresponds to the distance of the point to the origin, as shown in Figure 13.10.)Design a class named Complex for representing complex numbers and the methods add, subtract, multiply, divide, and abs for performing complex…arrow_forwardIn CORAL LANGUAGE please and thank you! Summary: Given integer values for red, green, and blue, subtract the gray from each value. Computers represent color by combining the sub-colors red, green, and blue (rgb). Each sub-color's value can range from 0 to 255. Thus (255, 0, 0) is bright red, (130, 0, 130) is a medium purple, (0, 0, 0) is black, (255, 255, 255) is white, and (40, 40, 40) is a dark gray. (130, 50, 130) is a faded purple, due to the (50, 50, 50) gray part. (In other words, equal amounts of red, green, blue yield gray). Given values for red, green, and blue, remove the gray part. Ex: If the input is: 130 50 130 the output is: 80 0 80 Hint: Find the smallest value, and then subtract it from all three values, thus removing the gray.arrow_forwardWritten in C# Language Please! A fixed percentage of water is taken from a well each day. Request values for W and P where: ▪ W is the amount (in litres) of water in the well at the start of the first day ▪ P is the percentage of the water in the well taken out each day Write a program to print the number of the day, the amount taken for that day and the amount remaining at the end of the day. The output should be terminated when 30 days have been printed or the amount of water remaining is less than 100 litres, whichever comes first. For example, if W = 1000 and P = 10, the output should start as follows: Day Amount Taken Amount Remaining 1 100 900 2 90 810 3 81 729 Note: The amount taken and amount remaining should be displayed to 2 decimal places.arrow_forward
- A nutritionist who works for a fitness club helps members by evaluating their diets. As part of her evaluation, she asks members for the number of fat grams and carbohydrate grams that they consume in a day. Then, she calculates the number of calories that result from the fat using the following formula: Calories from fat = Fat grams × 9Next, she calculates the number of calories that result from the carbohydrates using the following formula: Calories from carbs = Carbs grams × 4Create an application that will make these calculations. In the application, you should have the following methods:• FatCalories–This method should accept a number of fat grams as an argument and return the number of calories from that amount of fat.• CarbCalories–This method should accept a number of carbohydrate grams as an argument and return the number of calories from that amount of carbohydrates.arrow_forwardWhen 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_forwardSlove by pythonarrow_forward
- Q7: Code a complete Python program that performs the following operations by reading the weight of athletes until a zero is entered on the keyboard. When a negative value is entered by mistake from the keyboard, it should ask to enter the value again. How many athlete weights have been entered, Average weight of all athletes, Programmer must find out how many athletes are in each weight. Weight weight <50 Lightweight 50≤ kg <70 Middleweight Higher Heavyweight SAMPLE RUN Enter weight: 30 Enter weight: 65 Enter weight: 90 Enter weight: 120 Enter weight: 0 ------------------------------------- There are 1 light, 1 medium and 2 heavy weightsarrow_forwardCode in Pythonarrow_forwardPython questionarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
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