comp

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Write a Python statement to display the following, using single quote(') for the string: "When I say 'immediately,' I mean sometime before August," said the manager.

"When I say\'immediately'\i men sometime before august," """said the manager""

Write a python program: Get input of two integers from user, compare and output the greatest number.

# Get input of two integers from the user num1 = int(input("Enter the first integer: ")) num2 = int(input("Enter the second integer: ")) # Compare the integers and output the greatest number if num1 > num2: print(f"{num1} is greater than {num2}") elif num2 > num1: print(f"{num2} is greater than {num1}") else: print("The two integers are equal")

What are the values that the variable num contains through the iterations of the following for loop? for num in range(4):

0, 1, 2, 3

What is the output of the following code, given that x=1 and y=10? if x>0: print(x) if x >y: print("Great") else:print("It is OK.") else:print("Sorry.") print("Done")

1 It is OK. Done

What is the value of count after the following code is executed?

12

What is the output of the following code? val = 123.456789 print(f'{val:.3f}')

123.457

what is the decimal value of the following binary number? 10011000

152

What is the output of the following codes: x=5 y=3 print((x+y)%y)

2

What is the largest value that can be stored in one byte?

255

What is the output of the following statement? print(f'{0.3155:.0%}')

32%

Write a Python statement for this compound interest formula, use proper variable names.

A=P*(1+r/100)**n

Which computer language uses short words known as mnemonics for writing programs?

Assembly

Which language is referred to as a low-level language?

Assembly language

What is the output of the following code: PI=3.1415926 r=10 CircleArea=PI*r**2 print(f'Circle area = {CircleArea:.2f}')

Circle area = 314.16

The Python language uses a compiler which is a program that both translates and executes the instructions in a high-level language.

False

what is the result of the following Boolean expression, given that x = 5, y = 3, and z= 8? not (x < y or z > x) and y < z

False

what is wrong with the following code? multiple errors. List the line number and explain why it is wrong. Line 1: sales=input("Enter the sales amount: ") Line 2: TAX=7% Line 3: total Sales=sales+sales x TAX Line 4: print('Total sales: {total Sales: .2f}')

Graded line 1 needs to have an int varaible if a whole number or float if decimal value in order to be used in the equation line 2 can not use % because it means remainder can be typed as 0.07 line3 does not have the proper form of the multiplication which is * not x line 4 the print statement does not include f string(f') when starting the code so it will not work and {total Sales: .2f} will be useless. it is only used with f' sales = input("Enter the sales amount: ") TAX = 0.07 total_sales = float(sales) + float(sales) * TAX print(f'Total sales: {total_sales:.2f}')

web camera

Input device

What does the following program do?

It accepts 3 test scores for each of 3 students and outputs the average for each student.

What is wrong in the following code? Explain with the line number. Line 1: if (month<12) Line 2: month=month+1 line 3: else line 4: month=1What is wrong in the following code? Explain with the line number.

Line 1: The if statement is not properly closed with a colon (:) character. The correct syntax for an if statement in Python requires a colon at the end of the condition. Line 3: The else statement should be on the same line as the previous statement. In Python, the else statement is part of the same block as the previous if statement, so it should not be on a separate line.

RAM

Main memory

console

Output device

what is the output of the following code: print("Python is \n\tthe most popular\n\tprogramming language")

Python is the most popular programming language

SSD

Secondary Storage

RAM is a volatile memory used for temporary storage while a program is running

True

The instruction set for a microprocessor is unique and is typically understood only by the microprocessors of the same brand.

True

what is the result of the following Boolean expression, given that x = 5, y = 3, and z = 8? x < y or z > x

True

The following code is to get user's input for age. so variable age is integer type. age=input("input you age: ")

false

The process known as the __________ cycle is used by the CPU to execute instructions in a program.

fetch-decode-execute

which of the following is the correct if clause to determine whether choice is anything other than 10?

if choice != 10:

Which of the following is the correct if clause to determine whether y is in the range 10 through 50, inclusive?

if y >= 10 and y <= 50:

Where does a computer store a program and the data that the program is working with while the program is running?

in main memory

Which is correct boolean expression in Python for the following condition? The value of variable val is not in the range of 10 to 20.

not(val>=10 and val<=20)

Write a Python program. user inputs an integer, The program outputs "zero", "positive" or "negative" based on user's input.

num = int(input("Enter an integer: ")) # Check if the number is zero, positive, or negative, and output the result if num == 0: print("The number is zero") elif num > 0: print("The number is positive") else: print("The number is negative")

when using the __________ logical operator, one or both of the subexpressions must be true for the compound expression to be true.

or

What is the informal language, used by programmers to create models of programs, that has no syntax rules and is not meant to be compiled or executed?

pseudocode

Which of the following represents an example to calculate the sum of numbers (that is, an accumulator), given that the number is stored in the variable number and the total is stored in the variable total?

total += number

A good way to repeatedly perform an operation is to write the statements for the task once and then place the statements in a loop that will repeat as many times as necessary.

true

The following two statements will iterate the same number of loops. for num in range(1,100): for num in range(100, 1, -1):

true

When will the following loop terminate? while keep_going != 999:

when keep_going refers to a value equal to 999


Set pelajaran terkait

PSSI - Chapter 2 Reading Check Quiz

View Set

managerial accounting chapter 13

View Set

Chapter 10 : Gastrointestinal Tract - REVIEW QUESTIONS

View Set

Chapter 7- Consumers, Producers, and the Efficiency of Markets

View Set

Ch 11. Boolean Algebra & Logic Gates

View Set