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 9MC
Program Description Answer
The abbreviated form of GIGO is “garbage in, garbage out”.
Hence, the correct answer is option “B”.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Course Level Programming Assignment - Programming a Calculator using Python
In this assignment you will write a computer program from scratch using the Python programming language. This program will function as a simple calculator.
Objectives
• Write a simple Python program that performs arithmetic operations based on the user input
Stage 1: A simple calculator
Your calculator should provide the following arithmetic and control operations.
• Arithmetic Operations
• Addition (+)
add(a,b)
subtract(a,b)
• Subtraction (-)
• Multiplication (*)
• Division (/)
multiply(a,b)
divide(a,b)
power(a,b)
remainder(a,b)
• Power (^)
• Remainder (%)
• Control Operations
o Terminate (#)
o Reset ($)
Write a function select op(choice) to select the appropriate mathematics function based on the users selection.
The behavior of the program should be as follows:
You can start
• The program should ask the user to specify the desired operation…
main.py
import arithmetic
import data
def calculate (number):
return number
- 3
data.py arithmetic.py
print (arithmetic.calculate (data.large))
print (calculate (data.large))
main.py
small = 7
medium = 40
large = 900
main.py
Type the program
data.py arithmetic.py
Type the program
data.py arithmetic.py
def calculate (number):
return number * 5
In java, float takes _________ bytes in memory.
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
- The instructions is on the right side.arrow_forwardUSER REQUIREMENTS: 1. Create a new project and name it pa5_- 2. Use the one-dimensional arrays that we have discussed in writing this program. 3. Write a program that checks if two arrays are equal. Arrays are said to be equal and the same if all elements of one array are exactly the same with another array. SAMPLE OUTPUT: 4. The user may enter the size of the array from 3 - 10 only. 5. If the two arrays are alike, display the message "The two arrays are equal." Otherwise, display the index and the elements which are not the same. 6. Provide all possible validations. 7. See sample output below. Enter desired size of the array: 5 Enter elements for Array 1: 56 0 9 11 3 Enter elements for Array 2: 56 0 9 11 3 The two arrays are equal. Try Again [YIN]? Yarrow_forwardPROBLEMS SUBMIT CODE MY SUBMISSIONS STATUS STANDINGS CUSTOM INVOCATION O. Five in One time limit per test: 1 second® memory limit per test: 256 megabytes input: standard input output: standard output Given an array A of size N. write five functions that do the following: 1. Get the value of the maximum number in the array. 2. Get the value of the minimum number in the array. 3. Count the prime numbers in the array. 4. Count the palindrome numbers in the array. 5. Get the number that has the maximum number of divisors, and if there are more than one number that has the maximum number of divisors , print the maximum of them. Note: *A palindrome number is a number that reads the same forward or backward. For example: 12321, 101 are palindrome numbers, while 1201, 221 are not. *A prime number is a number that is greater than 1 and has only two factors which are 1 and itself. In other words : prime number divisible only by 1 and itself. Be careful that 1 is not prime. The first few prime…arrow_forward
- This is a main module. w7_main Module (supplied) Do not modify this module! Look at the code and make sure you understand it. // Workshop 7 // Version: 1.0 // Author: Asam Gulaid // Description: // This file tests your workshop 7 ///////////////////////////////////////////// #include<iostream> #include "Minister.h" #include "Minister.h" // intentional #include "MemberParliament.h" #include "MemberParliament.h" // intentional using namespace std; using namespace sdds; void printHeader(const char* title) { char oldFill = cout.fill('-'); cout.width(62); cout << "" << endl; cout << "|> " << title << endl; cout.fill('-'); cout.width(62); cout << "" << endl; cout.fill(oldFill); } void newElections(Minister& aMinister, const char* district, const char* newPM, double year) { aMinister.NewDistrict(district); aMinister.changePM(newPM); aMinister.assumeOffice(year); cout << "Status of New Election " << aMinister << endl…arrow_forwardWith no error Instructions The files provided in the code editor to the right contain syntax and/or logic errors. In each case, determine and fix the problem, remove all syntax and coding errors, and run the program to ensure it works properly. An example of the program is shown below: Enter a number >> 56 Enter a larger number >> 111 83.5 is halfway between 56 and 111 Task 1: The DebugSix4 class compiles without error. Task 2: The DebugSix4 program accepts user input and displays the correct output.arrow_forwardCorrect and complete the following program. Hint: You may need to add a destructor. The output should be: ------------------------- BMW X5 1999 Ford Mustang 1969 Car: [Ford Mustang 1969] is deleted! Car: [BMW X5 1999] is deleted! ------------------------ #include <iostream> using namespace std; class Car { string brand; string model; int year; string getModel() { return model; } string getBrand() { return brand; } int getYear() { return year; } } // Constructor definition outside the class Car::Car(string x, int y, int x) { brand = x; model = y; year = z; } int main() { // Create Car objects and call the constructor with different values Car carObj1(); Car carObj2("Ford", "Mustang"); // Print values cout << carObj1.brand << " " << carObj1.model << " " << carObj1.year << "\n"; cout << carObj2.brand << " " << carObj2.model…arrow_forward
- **** In Java Please **** Task : Please write a program or a code to calculate the frequency percentage of the occurrences of the characters in a text file.arrow_forwardJava Program ASAP ************This program must work in hypergrade and pass all the test cases.********** The program down below does not work in Hypergrade and does not pass the test cases. Please modify it even more or create a new program so when I upload to hypergrade it passes the test cases. Thank you! For Test Case 1 first print out Please enter the file name or type QUIT to exit:\ then you type text1.txtENTER and it displays Stop And Smell The Roses./n there needs to be nothing after that. For test case 2 first print out Please enter the file name or type QUIT to exit: then you type txt1.txtENTER then it reads out File 'txt1.txt' is not found.\n Then it didplays Please re-enter the file name or type QUIT to exit:\n after the test file is not found. then you type in text1.txt and it displays stop and smell the roses.\n. For test case 3 first print out Please enter the file name or type QUIT to exit: then you type text2.txtENTER and it displays A true rebel you are!…arrow_forwardpython The intent of this program is to manage a set of contacts. Each contact will have data associated with it: Id – number/integer First Name – string Last Name – string Age – number/integer Phone Number – string Email – string Anything else you’d like to add to make yours unique (can result in extra credit) Gender – character or string (m/f/o) Twitter ID, Facebook Id, etc You must allow the customer to do the following actions on the contact list: List all contacts Add contact Delete contact Edit contact Exit program You should leverage a database (PostgreSQL) to save everything to the DB and read from it. You should use classes for this assignment. This means you should have two classes: Contact – all the attributes/properties described above with appropriate constructor. Methods: Add (constructor - __init__(p_id, p_fname, p_lname, p_age, p_phone, p_email, p_gender) Edit Contact List (contact_list) – built on Python list (or creating one within the constructor), you…arrow_forward
- Integer userValue is read from input. Assume userValue is greater than 10000 and less than 99999. Assign ten Thousands Digit with userValue's ten thousands place value. Ex: If the input is 17598, then the output is: The value in the ten thousands place is: 1 1 import java.util.Scanner; 2 3 public class ValueFinder { 4 5 6 7 8 9 10 11 12 13 14 15} public static void main(String[] args) { Scanner scnr = new Scanner(System.in); int userValue; int tenThousandsDigit; } userValue = scnr.nextInt(); *Your code goes here */ System.out.println("The value in the ten thousands place is: " + tenThousands Digit);arrow_forwardJAVA CODEarrow_forwardcalculate the number of memory bytes accessed by this program: void my_dgemv(int n, double* A, double* x, double* y) { double alpha=1.0, beta=1.0; int lda=n, incx=1, incy=1; cblas_dgemv(CblasRowMajor, CblasNoTrans, n, n, alpha, A, lda, x, incx, beta, y, incy); }arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTEBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT