What will be the output after the following code is executed and the user enters 75 and 0

If we don't specify the module name before calling a module function, the Python interpreter will ________.

try to find the function first within our program
immediately fail
ignore the function call
prompt the user to enter the module name

try to find the function first within our program

Python allows the programmer to work with text and number files.

TRUE
FALSE

The ZeroDivisionError exception is raised when the program attempts to perform the calculation x/y if y = 0.

TRUE
FALSE

If the last line in a file is not terminated with \n, the readline method will return the line without \n.

TRUE
FALSE

Strings can be written directly to a file with the write method, but numbers must be converted to strings before they can be written.

TRUE
FALSE

Which of the following describes what happens when a piece of data is written to a file?

The data is copied from a variable in the program to a file.
The data is copied from the program to a file.
The data is copied from a file object to a file.
The data is copied from a variable in RAM to a file.

The data is copied from a variable in RAM to a file.

Which type of file access jumps directly to a piece of data in the file without having to read all the data that comes before it?

numbered
text
sequential
random

Which mode specifier will open a file but not let you change the file or write to it?

'r'
'a'
'e'
'w'

Which method could be used to strip specific characters from the end of a string?

strip
rstrip
estrip
remove

Which statement can be used to handle some of the runtime errors in a program?

an exception handler statement
a try/except statement
a try statement
an exception statement

Given that the customer file references a file object, and the file was opened using the 'w' mode specifier, how would you write the string 'Mary Smith' to the file?

customer file.write('Mary Smith')
customer.input('Mary Smith')
customer.write('Mary Smith')
customer.write('w', 'Mary Smith')

customer.write('Mary Smith')

When a file has been opened using the 'r' mode specifier, which method will return the file's contents as a string?

get
read
write
input

Which of the following is the correct way to open a file named users.txt to write to it?

outfile = open('users.txt', 'w')
outfile = open('users.txt')
outfile = open('w', users.txt)
outfile = write('users.txt', 'w')

outfile = open('users.txt', 'w')

What will be the output after the following code is executed and the user enters 75 and 0 at the first two prompts?

def main():
try:
total = int(input("Enter total cost of items? "))
num_items = int(input("Number of items "))
average = total / num_items
except ZeroDivisionError:
print('ERROR: cannot have 0 items')
except ValueError:
print('ERROR: number of items cannot be negative')
main()

0
ERROR: cannot have 0 items
ERROR: number of items can't be negative
Nothing; there is no print statement to display average.

ERROR: cannot have 0 items

What will be the output after the following code is executed and the user enters 75 and -5 at the first two prompts?

def main():
try:
total = int(input("Enter total cost of items? "))
num_items = int(input("Number of items "))
average = total / num_items

except ZeroDivisionError:
print('ERROR: cannot have 0 items')

except ValueError:
print('ERROR: number of items cannot be negative')

main()

ERROR: cannot have 0 items
ERROR: number of items can't be negative
Nothing; there is no print statement to display average. The ValueError will not catch the error.
ERROR: number of items can't be negative
ERROR: cannot have 0 items

Nothing; there is no print statement to display average. The ValueError will not catch the error.

What will be the output after the following code is executed and the user enters 75 and 0

Transcribed Image Text:What will be the output after the following code is executed and the user enters 75 and -5 at the first two prompts? def main(): try: total = int (imput ("Enter total cost of items? ")) num items = int (input ("Number of items ")) average = total / num items except ZeroDivisionError: print ('ERROR: cannot have 0 items') except ValueError: print ('ERROR: number of items cannot be negative') main() Select one: O A. ERROR: cannot have 0 items O B. ERROR: cannot have 0 items ERROR: number of items can't be negative O C. ERROR: number of items can't be negative O D. Nothing; there is no print statement to display average. The valueError will not catch the error.

What will be the output after the following code is executed and the user enters 75 and 0

What will be the output after the following code is executed and the user enters 75 and 0

Q: When the following program is executed, it terminates with an error. Which option best describes the…

A: Coded using Python 3. As per the guidelines we are supposed to answer single question so I am…

Q: public static char start(char key) { Scanner console = new Scanner(System.in); String prompt =…

A: The answer is No it is not testable. The reasons for this are :1. The code that you have given here…

Q: What would be the value of bonus after the following statements are executed? int bonus, sales =…

A: According to the question   Output:

Q: Write a switch statement that tests the value of the char variable response and performs the…

A: PROGRAM STRUCTURE: Include the required header files. Start the definition of the main function.…

Q: What is the output of the following code? const int SIZE 5; int count;int time[SIZE] = {1, 2, 3, 4,…

A: in the above code snippet a variable named 'size' is created with constant value 5 now in second…

Q: #What is output when the following code is executed? varx, varY = 12, 20 print (varY) if vary >=…

A: Given:

Q: 3. What is the value of the price variable after the following code snippet is executed? int price…

A: If-else statements determine whether the if expression is true or false. If it is true, then the if…

Q: Nhat are the values of mynum[0], mynum [1], and mynum[2] after the following code executes? double[]…

A: this is a simple output based question

Q: CHALLENGE 1.3.4: Read user input numbers and perform a calculation. АCTIVITY Read two numbers from…

A: Here we have statement to accept the 1st number from user.  Now we need to use same statement to…

Q: I'm getting an error message where the FindText() is returning 0 instead of the proper amount of…

A: Coded in C++.

Q: After execution of the following code, what is stored in valueNum? All variables are using data type…

A: Given: All variables are using data type int. num1=3, num2=5,  num3=7. To Find, The value stored in…

Q: What will be the value of the variable z after execution of the following code? int n[10] = { 3, 5,…

A: Given code: int n[10]={3,5,2,11,4,15,2,7,3,1}; int k=3; int z=3; void setup() { switch(k){ case 0:…

Q: When the following program is executed, it terminates with an error. Which option best describes the…

A: def fox(bb,ss):    tt=ss;      #tt is initialized to ss    tt=tt+2;    #tt gets incremented by 2…

Q: With the statement. int grade- 70: ifgrade +706&gradec-100) printf("Passed ): With the statement.…

A: int grade = 70; if(grade > 70)      printf("Passed"); printf("Congratulation");   Answer is First…

Q: 5-3) (Find the highest score) Write a program that prompts the user to enter the number of students…

A: Click to see the answer

Q: Attached Question :

A: Since multiple questions have been posted at a single request, we will answer first question. If you…

Q: Q4) * What is the output after executing the following code? int D=90; switch (D) { case 90: if…

A: Given: To give the output of the given code.

Q: Q4) * What is the output after executing the following code? int D=90; switch (D) { case 90: if…

A: Here we have integer variable D, whose value is set to 90. Next, we have a switch case with D. In…

Q: 9. What will the following print out? int num - 0; System.out.println("Song titles with numbers…

A: Coded using Java.

Q: int numl, num2, num3; double length, width, height; double volume; numl = 6; num2 = 7; num3 = 4;…

A: volume = box(length, width, height);    valid. volume = box(length, 3.8, height);    valid. cout…

Q: What is the output of the following code? double balance[5] = {100.0, 250.0, 325.0, 500.0, 1100.0};…

A: Given: What is the output of the following code? double balance[5] = {100.0, 250.0, 325.0, 500.0,…

Q: What will be the output on screen after the following code is executed? int limit = 2, count=0;…

A: Given: A Java code having String str="H". Using a do-while loop some operation is done on the…

Q: How many times will the following code will print "Final Test"? int i = 1; do { System.out.println…

A: Task :- Choose the correct option for given question.

Q: How many times will the following code will print "Final Test"? int i = 0; while (i <= 4) {…

A: while keyword is used for iteration. To repeat a particular task multiple times iteration is used.

Q: CHALLENGE 1.24: Read multiple user inputs. ACTIVITY Write two scnr.nextint statements to get input…

A: Given below is the program to get input values for month and year and write the output value as a…

Q: 1. What is the output of the following code snipper? int num - 50; if (num > 50) : num - num -5:…

A: Question 1: The number is 50, so it will no enter the if clause and the output is 50. The answer is…

Q: Task 3: Find the numbers that can be expressed as the product of two nonnegative integers in…

A: Below is the required Flowchart: -

Q: int numl, num2, num3; double length, width, height; double volume; numl = 6; num2 = 7; num3 = 4; %3D…

A: a. Given statement: volume =box(length, width, height); Here, "box" is the method which is passed…

Q: What is the output of the following code segment? Assume user input is: soccer football void…

A: Task :- identify the output for given C++ code.

Q: What will be the value of pay after the following statements executed? int hours = 41; double pay,…

A: What will be the value of pay after the following statements executed?

Q: What will the following code segments print on the screen?1. int freeze = 32, boil = 212;freeze =…

A: Here first we declare  two variables freeze and boil and put 32 and 212 in it. int freeze = 32, boil…

Q: Question 3 Create THREE (3) overloading methods that can accept the following method calls:…

A: C++ Code with overloading methods is provided with sample output in step 2.

Q: Question 3: State if each of the following statements is true or false. Give reasons for your answer…

A: 1.private sub from_load()    shape1.shape=6     end sub                 - TRUE This will change the…

Q: What is the output after executing the following code? int D=90; switch (D) { case 90: if (D>90)…

A: A switch statement allows a variable to be tested for equality against a list of values.

Q: What is output by the following code segment ? (Supposed all variables are declared as int) count =…

A: The output of the given code segment is as follows:             0            00            000…

Q: Finding Errors. Identifying the line/s containing errors that can cause the program not to run.…

A: Program Errors: Errors are obstacles that prevent a program to be successfully compiled and…

Q: What is the final value of variable myNum after the following code fragment executes? int myNum = 0;…

A: From the above given options Option B will  be the correct answer Explanation: As we can see in the…

Q: 2. Write a program calculating the statistics for tests of a hospital by getting data from the user…

A: Algorithm Start Var t, pt, nt, ptr, ntr Accept total test in t Accept total positive test in pt…

Q: What is the output for the following java code? int index = 0; int result = 1; while ( true )…

A: Hello Student Greetings Hope you are doing great. I will try my best to answer your question. Thank…

Q: 1- Question What will be the output of following piece of code? System.out.println("The result is "…

A: Here inside System.out.println() We divide 7 by 2 As both 7 and 2 are of integer type. The result we…

Q: What is wrong with the following code, if anything?   Note: you may assume there are no syntax…

A: The given C++ program is: int a=0;int count;ifstream iFile;int sum=0;iFile.open( "data.txt");if (…

Q: What values are returned by each of the following?a. Math.round(2.3)b. Math.round(2.7)c.…

A: Math.round() method In Java, the Math.round() function is used to round numbers to the nearest…

Q: The value of R after executing the following program, where M=15, L=8 is: Private Sub Command1_Click…

A: Given M=15 L=8 ------------------------- M&lt;5  =&gt; 15&lt;5(False)

Q: Type your answer to "Plus 7 times 2" here. Write a program that asks the user for a number, and adds…

A: Here I ahve taken input from the user and then stored it into the variable. Next, I have added 7 to…

Q: What is the output of the following, if n=1, n=2, n=3, n=4, and n=5, respectively?   int n =…

A: for n=1  it will print less than 3   for n=2 it will print less than 3   for n=3 it will print less…

Q: What is the output of this code? def main(): x = myfun(5) y = myfun(4) z = myfun(2) print(x + y + z)…

A: X = myfun(5) will call the function myfun with p=5 So the function will return value 15 which will…

Q: CHALLENGE 1.6.4: Read user input numbers and perform a calculation. ACTIVITY Read two numbers from…

A: GIVEN:

Q: What is the sentinel value in the following code snippet? int main() { int score = 0; int…

A: In the given code snippet, -1 is the sentinel value.

Q: QUESTION 15 What is the result of executing the following code? public claas Test ( public static…

A: The main function is making function call doTask(3). This will call the 2nd function since we are…

Q: Suppose the user is asked to input a number into txtNumber for which the square root is to be taken.…

A: SOLUTION:-

Knowledge Booster

Recommended textbooks for you

  • What will be the output after the following code is executed and the user enters 75 and 0

    Computer Networking: A Top-Down Approach (7th Edi...

    ISBN:9780133594140

    Author:James Kurose, Keith Ross

    Publisher:PEARSON

    What will be the output after the following code is executed and the user enters 75 and 0

    Computer Organization and Design MIPS Edition, Fi...

    ISBN:9780124077263

    Author:David A. Patterson, John L. Hennessy

    Publisher:Elsevier Science

    What will be the output after the following code is executed and the user enters 75 and 0

    Network+ Guide to Networks (MindTap Course List)

    ISBN:9781337569330

    Author:Jill West, Tamara Dean, Jean Andrews

    Publisher:Cengage Learning

  • What will be the output after the following code is executed and the user enters 75 and 0

    Concepts of Database Management

    ISBN:9781337093422

    Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last

    Publisher:Cengage Learning

    What will be the output after the following code is executed and the user enters 75 and 0

    Prelude to Programming

    ISBN:9780133750423

    Author:VENIT, Stewart

    Publisher:Pearson Education

    What will be the output after the following code is executed and the user enters 75 and 0

  • What will be the output after the following code is executed and the user enters 75 and 0

    Computer Networking: A Top-Down Approach (7th Edi...

    ISBN:9780133594140

    Author:James Kurose, Keith Ross

    Publisher:PEARSON

    What will be the output after the following code is executed and the user enters 75 and 0

    Computer Organization and Design MIPS Edition, Fi...

    ISBN:9780124077263

    Author:David A. Patterson, John L. Hennessy

    Publisher:Elsevier Science

    What will be the output after the following code is executed and the user enters 75 and 0

    Network+ Guide to Networks (MindTap Course List)

    ISBN:9781337569330

    Author:Jill West, Tamara Dean, Jean Andrews

    Publisher:Cengage Learning

    What will be the output after the following code is executed and the user enters 75 and 0

    Concepts of Database Management

    ISBN:9781337093422

    Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last

    Publisher:Cengage Learning

    What will be the output after the following code is executed and the user enters 75 and 0

    Prelude to Programming

    ISBN:9780133750423

    Author:VENIT, Stewart

    Publisher:Pearson Education

    What will be the output after the following code is executed and the user enters 75 and 0

    What will be the output after the following code is executed and the user enters 75 and?

    what will be the output after the following code is executed and the user enters 75 and 0 at the first two prompts? nothing; there is no print statement to display average. The ValueError will not catch the error.

    What does the following statement mean num1 num2 Get_num ()?

    What does the following statement mean? num1, num2 = get_num() The function get_num() is expected to return a value each for num1 and num2. The randrange function returns a randomly selected value from a specific sequence of numbers.

    Which of the following describes what happens when a piece of data is written to a file quizlet?

    Which of the following describes what happens when a piece of data is written to a file? The data is copied from a variable in RAM to a file.

    Which method will return an empty string when it has attempted to read beyond the end of a file?

    Note that the readline method returns an empty string ( "" ) when it attempt to read beyond the end of the file.