Python Programming: An Introduction to Computer Science, 3rd Ed.
Python Programming: An Introduction to Computer Science, 3rd Ed.
3rd Edition
ISBN: 9781590282755
Author: John Zelle
Publisher: Franklin, Beedle & Associates
bartleby

Concept explainers

bartleby

Videos

Question
Book Icon
Chapter 7, Problem 4PE
Program Plan Intro

Print class

Program plan:

  • Define the function “main()”,
    • Get the number of credits from the user using “input()” method.
    • Check whether the score is less than “7” and not less than “1” using “if” statement,
      • If it is true, print the class as “Freshman”.
    • Otherwise, check whether the n of credits is lies between “7” and “15” using “elif” statement,
      • If it is true, then print the class as “Sophomore”.
    • Otherwise, check whether the score is lies between “16” and “25” using “elif” statement,
      • If it is true, print the class as “Junior”.
    • Otherwise, check whether the score is greater than or equal to “26” using “elif” statement,
      • If it is true, print the class as “Senior”.
    • Otherwise, print the string “Please enter a valid positive number”.
  • Call the function “main()”.

Blurred answer
Students have asked these similar questions
Interest Rates Savings accounts state an interest rate and a compounding period. If theamount deposited is P, the stated interest rate is r, and interest is compounded m timesper year, then the balance in the account after one year is P⋅(1+rm)m. For instance, if$1000 is deposited at 3% interest compounded quarterly (that is, 4 times per year), thenthe balance after one year is1000⋅(1+.034)4=1000⋅1.00754=$1,030.34.Interest rates with different compounding periods cannot be compared directly.The concept of APY (annual percentage yield) must be used to make the comparison. TheAPY for a stated interest rate r compounded m times per year is defined byAPY=(1+rm)m−1.(The APY is the simple interest rate that yields the same amount of interest after oneyear as the compounded annual rate of interest.) Write a program to compare interestrates offered by two different banks and determine the most favorable interest rate. SeeFig. 4.24.
Periodic compounding The total accumulated value, including the principal sum P, is given by the formula: where: nt A = P(1 + 1) "² n A is the final amount Accumulated Value P is the original principal sum r is the nominal annual interest rate n is the compounding frequency t is the overall length of time the interest is applied (expressed using the same time units as r, usually years). Using the above formula write a program that will display the following table. Principal-Value | Times-Interest-Compunded | Annual-Int-Rate | Term | Accumulated-Value 1000 6.00% 10 3.20% 15 2000 3000 9.25% 10 2 ** 3 8 | You must use exponent operator to compute P Exponent Operator in Python is ** Examples m=3 n=2 p= m **n (https://en.wikipedia.org/wiki/Compound_interest) 1 2 4 base = 2 exp = 4 a = base ** exp print(a) 16 print("Solving the exponent, we get Solving the exponent, we get 9 ,p ) 1790.85 3219.89 7486.33
Golf scores record the number of strokes used to get the ball in the hole. The expected number of strokes varies from hole to hole and is called par (i.e. 3, 4, or 5). Each score's name is based on the actual strokes taken compared to par: "Eagle": number of strokes is two less than par "Birdie": number of strokes is one less than par "Par": number of strokes equals par "Bogey": number of strokes is one more than par Given two integers that represent par and the number of strokes used, write a program that prints the appropriate score name. Print "Error" if par is not 3, 4, or 5. Ex: If the input is: 4 3 the output is: Birdie (in java please)
Knowledge Booster
Background pattern image
Computer Science
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
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
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