Starting Out with Python (3rd Edition)
3rd Edition
ISBN: 9780133582734
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 2.7, Problem 21CP
Program Plan Intro
Reminder operator:
In Python, “%” symbol is called as a remainder operator or modulus operator.
- • The remainder operator performs division operation, but it will return the remainder value instead of returning the quotient value.
- • In many languages, the operands of the remainder operator have an integer, but in Python, both operands can be either “int” or “float”.
Syntax:
Consider the syntax of remainder operator as follows:
variable = a % b
Here, “a” and “b” are the operands and the remainder value is stored in “variable”.
Example:
Consider the example of the remainder operator as follows:
value = 10 % 3
Here, the value “10” is divided by the value “3” and the remainder value “1” is stored in “value” variable.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
12-
What will be the result after executing this statement:
SELECT INITCAP('bakhit said ahmed') FROM dual?
a.
bakhit said ahmed
b.
BAKHIT SAID AHMED
c.
Bakhit Said Ahmed
d.
BaKhIt SaId AhMeD
A game program contains the following code to update three score variables, health, food, and knowledge. The maximum values for the three variables are 100, 80, and 25, respectively.
The game program’s author would like to write a procedure that could be used to update any variable in the game (myScore) that has a maximum value (myLimit) by a given amount (myAmount). A correct call of the procedure is shown below.
Which of the following is a correct implementation of updateScore ?
4 answer options in picture below, full question in other pic
says that the value retuned is incorrect
Chapter 2 Solutions
Starting Out with Python (3rd Edition)
Ch. 2.1 - Who is a programmers customer?Ch. 2.1 - What is a software requirement?Ch. 2.1 - What is an algorithm?Ch. 2.1 - What is pseudocode?Ch. 2.1 - Prob. 5CPCh. 2.1 - Prob. 6CPCh. 2.3 - Write a statement that displays your name.Ch. 2.3 - Write a statement that displays the following...Ch. 2.3 - Write a statement that displays the following...Ch. 2.5 - Prob. 10CP
Ch. 2.5 - Which of the following are illegal variable names...Ch. 2.5 - Prob. 12CPCh. 2.5 - Is the following assignment statement valid or...Ch. 2.5 - Prob. 14CPCh. 2.5 - Look at the following assignment statements:...Ch. 2.5 - What will be displayed by the following program?...Ch. 2.6 - You need the user of a program to enter a...Ch. 2.6 - Prob. 18CPCh. 2.7 - Prob. 19CPCh. 2.7 - Prob. 20CPCh. 2.7 - Prob. 21CPCh. 2 - A ______ error does not prevent the program from...Ch. 2 - Prob. 2MCCh. 2 - A(n) __________ is a set of well-defined logical...Ch. 2 - An Informal language that has no syntax rules and...Ch. 2 - A _______ is a diagram that graphically depicts...Ch. 2 - A ______ is a sequence of characters. a. char...Ch. 2 - Prob. 7MCCh. 2 - Prob. 8MCCh. 2 - A string literal in Python must be enclosed in...Ch. 2 - Prob. 10MCCh. 2 - A(n) __________ makes a variable reference a value...Ch. 2 - This symbol marks the beginning of a comment in...Ch. 2 - Which of the following statements will cause an...Ch. 2 - In the expression 12 + 7, the values on the right...Ch. 2 - This operator performs integer division. a. // b....Ch. 2 - This is an operator that raises a number to a...Ch. 2 - This operator performs division, but instead of...Ch. 2 - Prob. 18MCCh. 2 - Which built-in function can be used to read input...Ch. 2 - Prob. 20MCCh. 2 - Programmers must be careful not to make syntax...Ch. 2 - In a math expression, multiplication and division...Ch. 2 - Variable names can have spaces in them.Ch. 2 - In Python, the first character of a variable name...Ch. 2 - If you print a variable that has not been assigned...Ch. 2 - What does a professional programmer usually do...Ch. 2 - What is pseudocode?Ch. 2 - Computer programs typically perform what three...Ch. 2 - If a math expression adds a float to an int, what...Ch. 2 - What is the difference between floating-point...Ch. 2 - Write Python code that prompts the user to enter...Ch. 2 - Write Python code that prompts the user to enter...Ch. 2 - Write assignment statements that perform the...Ch. 2 - Assume the variables result, w, x, y, and z are...Ch. 2 - Write a Python statement that assigns the sum of...Ch. 2 - Write a Python statement that subtracts the...Ch. 2 - Write a Python statement that multiplies the...Ch. 2 - Prob. 8AWCh. 2 - What would the following display? num = 99 num = 5...Ch. 2 - Assume the variable sales references a float...Ch. 2 - Assume the following statement has been executed:...Ch. 2 - What will the following statement display?...Ch. 2 - Personal Information Write a program that displays...Ch. 2 - Sales Prediction A company has determined that its...Ch. 2 - Land Calculation One acre of land is equivalent to...Ch. 2 - Total Purchase A customer in a store is purchasing...Ch. 2 - Distance Traveled Assuming there are no accidents...Ch. 2 - Sales Tax Write a program that will ask the user...Ch. 2 - Miles-per-Gallon A car's miles-per-gallon (MPG)...Ch. 2 - Tip, Tax, and Total Write a program that...Ch. 2 - Celsius to Fahrenheit Temperature Converter Write...Ch. 2 - Ingredient Adjuster A cookie recipe calls for the...Ch. 2 - Male and Female Percentages Write a program that...Ch. 2 - Stock Transaction Program Last month, Joe...
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
- Why should you be careful when choosing a sentinel value?arrow_forward11- What will be the result after executing this statement: SELECT SUBSTR('Specialization', 1, 7) FROM dual? a. S b. lization c. pecial d. Specialarrow_forward/ create the following functions: GetInteger - returns an integer DONE GetDouble - returns a double CheckInteger (called from GetInteger) - checks the range of an integer CheckDouble(called from GetDouble) - checks the range of a doubleCalculateSum - overloaded for integers and doubles as parameters DONE CalculateProduct - overloaded for integers and doubles as parameters DONE ShowSums - shows the sums of integers and the sum of doubles ShowProducts - shows the products of integers and the product of doubles. if you can create a function ShowInstructions that passes the type (integer or double) as a string. ShowInstructionsIntegers and ShowInstructionsDoublesarrow_forward
- 1- You are required to draw flow chart and write a Pseudocode for the followingproblem statement.Muscat MobiCare is a Mobile Outlet, which provides Mobile repair services. The charges of mobilerepairs are based on the type of the service.Details of charges are as follow:Software Fault: 4 OMRScreen Fault: 6 OMRNetwork/Wi-Fi Fault: 8 OMRInternal Hardware Fault: 10 OMRThe Outlet offers discount to the loyal customers. The discount is offered based on the customervisits to the outlet.Following is the detail of discounts.1- Customer visiting 4 times a year gets 20% discount.2- Customer visiting 6 times a year gets 30% discount.3- Customer visiting 8 times a year gets 50% discount.You are required to draw a Flow Chart diagram and write a Pseudocode for a computer programthat takes customer name, mobile model, visit date, total number of visits, and required service(mentioned above). The program outputs a receipt with all the entered information plus repaircharges based on the required…arrow_forwardTrue or false ?arrow_forwardhelparrow_forward
- QUESTION 25 Write conditional expression(ternary operator) that returns -1 or 1 randomly.arrow_forwardExplain procedure return code briefly.arrow_forwardUsage: mortgagepmt [-s] -r rate [-d downpayment] price In this assignment, you are asked to do a mortgage payment calculation. All information needed for this will be passed to the program on the command line. There will be no user input during the execution of the program. You will need a few pieces of information. The price of the home and the amount of the down payment. You will also need to know the interest rate and the term of the mortgage. To figure your mortgage payment, start by converting your annual interest rate to a monthly interest rate by dividing by 12. Next, add 1 to the monthly rate. Third, multiply the number of years in the term of the mortgage by 12 to calculate the number of monthly payments you’ll make. Fourth, raise the result of 1 plus the monthly rate to the negative power of the number of monthly payments you’ll make. Fifth, subtract that result from 1. Sixth, divide the monthly rate by the result. Last, multiply the result by the amount you want to borrow.…arrow_forward
- Assume that grade is a variable whose value is a letter student_grade-- any one of the following letters: 'A', 'B', 'C', 'D', 'F". Assume further that there are the following int variables, declared and already initialized: acount, bcount, ccount, dcount, fcount. Write a switch statement that increments the appropriate variable (acount, bcount, ccount, etc.) depending on the value of grade. So if grade is 'A' then acount is incremented; if grade is'B' then bcount is incremented, and so on.arrow_forwardProvide description on how to use the code. Code is located below: # initialize a flag variable with 0flag = 0 # loop will execute till flag is 0 in the sense loop will execute codewhile flag == 0 : #until amount is greater then costcost = float(input("Enter the cost: ")) # take input cost and convert to floating data typeamount = float(input("Enter the amount given(should be greater than cost): ")) # take inputif amount < cost :print("Amount should be greater than cost.") #print statement saying enter Amount thatelse:flag = 1 # when amount entered by user greater then cost flag is set to 1 and while loop will not execute change = amount-cost #stored difference between amount and cost to change variableprint(f"The change to be given is ${change}") #print the value of change variable twenty=0 #intializing all possible coin/ notes to 0ten=0five=0single=0quarter=0dime=0nickel=0penny=0 while change>=20 : #loop will execute until change become less then 20. this loop execute for…arrow_forwardProgram Purpose - Professional Athletes often hire other professionals to help take care of matters for them. We will group them in four categories: Lawyers, Personal Assistants, Agents, and Trainers. They all get paid a percentage of the athlete's total yearly salary. Lawyers - 10%, Personal Assistants - 3%, Agents - 7%, and Trainers - 5% . Prompt the user to enter the athlete's salary for the year (ensure that the entered value is positive). The user should then enter the name and category of each of the hired professionals. The athlete should be able to hire as many professionals in each category as he/she wants, even if it is more than he/she can afford. Based on the category, calculate the amount that each professional should be paid. After all data has been entered, print the names of each professional hired, how much each is being paid, the total amount the athlete paid, and how much the athlete has left.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningProgramming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage Learning
- LINUX+ AND LPIC-1 GDE.TO LINUX CERTIF.Computer ScienceISBN:9781337569798Author:ECKERTPublisher:CENGAGE LNp Ms Office 365/Excel 2016 I NtermedComputer ScienceISBN:9781337508841Author:CareyPublisher:CengageProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
LINUX+ AND LPIC-1 GDE.TO LINUX CERTIF.
Computer Science
ISBN:9781337569798
Author:ECKERT
Publisher:CENGAGE L
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:9781337508841
Author:Carey
Publisher:Cengage
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage