Starting Out with Python (4th Edition)
4th Edition
ISBN: 9780134444321
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Expert Solution & Answer
Chapter 4, Problem 7MC
Program Description Answer
In the above code, the running total is calculated using the accumulator variable.
Hence, the correct answer is option “D”.
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
JAVA:
1 # SuperMarket.py - This program creates a report that lists weekly hours work
The student file provided for this lab includes the necessary variable declarations and input and
2 # by employees of a supermarket. The report lists total hours for
output statements. You need to implement the code that recognizes when a control break should
3 # each day of one week.
occur. You also need to complete the control break code. Be sure to accumulate the daily totals
4 # Input: Interactive
5 # Output: Report.
for all days in the week.
6.
7 # Declare variables.
Comments in the code tell you where to write your code.
8 HEAD1 = "WEEKLY HOURS WORKED"
9 DAY_FOOTER = "Day Total "
10 SENTINEL = "done"
Instructions
# Named constant for sentinel value
11 hoursWorked = 0
# Current record hours
12 hoursTotal = 0
# Hours total for a day
1. Study the prewritten code to understand what has already been done.
|13 prevDay = ""
|14 notDone = True
# Previous day of week
2. Write the control break code
# loop…
The ________ function returns no value. a) malloc() b) realloc() c) free() d) calloc()
Chapter 4 Solutions
Starting Out with Python (4th Edition)
Ch. 4.1 - What is a repetition structure?Ch. 4.1 - What is a condition-controlled loop?Ch. 4.1 - What is a count-controlled loop?Ch. 4.2 - What is a loop iteration?Ch. 4.2 - Does the while loop test its condition before or...Ch. 4.2 - How many times will 'Hello world' be printed in...Ch. 4.2 - What is an infinite loop?Ch. 4.3 - Rewrite the following code so it calls the range...Ch. 4.3 - What will the following code display? For number...Ch. 4.3 - What will the following code display? for number...
Ch. 4.3 - What will the following code display? for number...Ch. 4.3 - What will the following code display? for number...Ch. 4.4 - Prob. 13CPCh. 4.4 - Should an accumulator be initialized to any...Ch. 4.4 - What will the following code display? total - 0...Ch. 4.4 - What will the following code display? number 1 =...Ch. 4.4 - Rewrite the following statements using augmented...Ch. 4.5 - Prob. 18CPCh. 4.5 - Why should you take care to choose a distinctive...Ch. 4.6 - What does the phrase garbage in, garbage out mean?Ch. 4.6 - Give a general description of the input validation...Ch. 4.6 - Describe the steps that are generally taken when...Ch. 4.6 - Prob. 23CPCh. 4.6 - If the input that is read by the priming read is...Ch. 4 - A_________-controlled loop uses a true/false...Ch. 4 - A _____-controlled loop repeats a specific number...Ch. 4 - Each repetition of a loop is known as a(n) a cycle...Ch. 4 - The while loop is a _______ type of loop. a....Ch. 4 - A(n) ______ loop has no way of ending and repeats...Ch. 4 - The -= operator is an example of a(n) _________...Ch. 4 - Prob. 7MCCh. 4 - A(n) ____________ is a special value that signals...Ch. 4 - Prob. 9MCCh. 4 - The integrity of a programs output is only as good...Ch. 4 - The input operation that appears just before a...Ch. 4 - Validation loops are also known as _________. a....Ch. 4 - A condition-controlled loop always repeats a...Ch. 4 - The while loop is a pretest loop.Ch. 4 - The following statement subtracts 1 from x: x = x ...Ch. 4 - It is not necessary to initialize accumulator...Ch. 4 - In a nested loop, the inner loop goes through all...Ch. 4 - To calculate the total number of iterations of a...Ch. 4 - The process of input validation works as follows:...Ch. 4 - What is a condition-controlled loop?Ch. 4 - What is a count-controlled loop?Ch. 4 - What is an infinite loop? Write the code for an...Ch. 4 - Why is it critical that accumulator variables are...Ch. 4 - What is the advantage of using a sentinel?Ch. 4 - Prob. 6SACh. 4 - What does the phrase garbage in, garbage out mean?Ch. 4 - Give a general description of the input validation...Ch. 4 - Write a while loop that lets the user enter a...Ch. 4 - Write a while loop that asks the user to enter two...Ch. 4 - Write a for loop that displays the following set...Ch. 4 - Write a loop that asks the user to enter a number....Ch. 4 - Write a loop that calculates the total of the...Ch. 4 - Rewrite the following statements using augmented...Ch. 4 - Write a set of nested loops that display 10 rows...Ch. 4 - Write code that prompts the user to enter a...Ch. 4 - Write code that prompts the user to enter a number...Ch. 4 - Bug Collector The Bug Collector Problem A bug...Ch. 4 - Calories Burned Running on a particular treadmill...Ch. 4 - Budget Analysis Write a program that asks the user...Ch. 4 - Distance Traveled The distance a vehicle travels...Ch. 4 - Average Rainfall Write a program that uses nested...Ch. 4 - Celsius to Fahrenheit Table Write a program that...Ch. 4 - Pennies for Pay Write a program that calculates...Ch. 4 - Sum of Numbers Write a program with a loop that...Ch. 4 - Ocean Levels Assuming the ocean's level is...Ch. 4 - Tuition Increase At one college, the tuition for a...Ch. 4 - Weight Loss If a moderately active person cuts...Ch. 4 - Calculating the Factorial of a Number In...Ch. 4 - Population Write a program that predicts the...Ch. 4 - Prob. 14PECh. 4 - Prob. 15PECh. 4 - Turtle Graphics: Repeating Squares In this...Ch. 4 - Turtle Graphics: Star Pattern Use a loop with the...Ch. 4 - Turtle Graphics: Hypnotic Pattern Use a loop with...Ch. 4 - Turtle Graphics: STOP Sign In this chapter, you...
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
- Please written by computer source # with visual studio. Windows Form app (.NET Framework)arrow_forwardY = Math.sqrt(4) * Math.abs(4)The value of Y is ______ a. 8 b. -16 c. 16 d. -8arrow_forwardDomino's Time Function Name: dominosTime() Parameters: N/A Returns: None Description: During the summer, you ordered a lot of food from Domino's. Pizzas are $12, an order of pasta is $6, and chicken wings are $8. Write a function that asks the user how many of each food item they would like, and then print a response telling them what their order to- tal will be. The order total should be an integer. >>> dominosTime() How many pizzas do you want? 3 How many orders of pasta do you want? 2 How many orders of chicken wings do you want? 2 By ordering 3 pizzas, 2 orders of pasta, and 2 orders of chicken wings, your order total comes to $64.arrow_forward
- function triangular_number() { echo "Enter the range of numbers (start end): " read start end even_count=0 odd_count=0 echo "------------------------------------------" for (( i=$start; $i<=$end; i++ )) do triangular=$(( (i*(i+1))/2 )) if [[ $triangular -gt $start && $triangular -lt $end && $((triangular%2)) -eq 0 ]]; then ((even_count++)) echo $triangular elif [[ $triangular -gt $stat && $triangular -lt $end ]]; then ((odd_count++)) fi done echo "------------------------------------------" echo "Total even triangular numbers found: $even_count" echo "Total odd triangular numbers found: $odd_count" } Make a flowchart with this code No hand written and fast answer with explanationarrow_forwardNonearrow_forwardWrite MARIE assembly language code to implement the following algorithm:arrow_forward
- Please draw the correct flowchart for this game ? # Function to display question and answer def new_game(): guesses = [] Right_guesses = 0 question_num = 1 num = 1 for key in questions: print("\n------------------------- \n") print("Question " + str(num) + "\n" ) num += 1 print(key) for i in options[question_num-1]: print(i) guess = input("\nAnswer (A, B, C, or D): ") guess = guess.upper() guesses.append(guess) Right_guesses += check_answer(questions.get(key), guess) question_num += 1 display_score(Right_guesses, guesses) # ------------------------- # Function to check answer def check_answer(answer, guess): if answer == guess: print("\nYour Answer Correct!") return 1 else: print("\nYour Answer Wrong!") return 0 # ------------------------- # Function to display score def display_score(Right_guesses, guesses):…arrow_forwardInput a value for the variable y so that the variable x becomes 4 after the code executes. favorite_numbers = y favorite_numbers.remove(-1) x = len(favorite_numbers)arrow_forwardpythonarrow_forward
- Aq1arrow_forwardIncrement Count Using Augmented Assignment Use an augmented assignment operator to increment the value stored in the variable count by one. Assume that count already has a value.arrow_forwarddef main(): monthlySales = getSales() printbonus=print_bonus(storeAmount,empAmount) #This function gets the monthly salesdef getSales(): monthlySales = float(input('Enter the monthly sales $')) monthlySales = getSales() #call to get sales salesIncrease = getIncrease(monthlySales) return monthlySales #This function gets the percent of increase in salesdef getIncrease(monthlySales): storeAmount = storeBonus(monthlySales) salesIncrease = float(input('Enter percent of sales increase: ')) salesIncrease = float(salesIncrease) salesIncrease = salesIncrease / 100 return salesIncrease #This function determines the storeAmount bonusdef storeBonus(monthlySales): if monthlySales >= 110000: storeAmount = 6000 elif monthlySales >= 100000: storeAmount = 5000 elif monthlySales >= 90000: storeAmount = 4000 elif monthlySales >=80000: storeAmount = 3000 else: storeAmount = 0 return storeAmount #This function…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,Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning