CS170 Quiz

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Which of the following is not a valid expression in Python? 9 - 7.8 1 ** 2 "5" + 3 "123" + "654"

"5 + 3

Which character starts a comment in a Python program? % # $ &

#

What's the output of the following code? #print("Hello, World!",sep="-") Hello- World! Hello, World! (no output, it's a comment) Hello-World!

(no output, it's a comment)

What is min(30, -5, 10, -7, 14)? 7 14 -5 -7 30

-7

25 % 1 is _____ 4 1 0 2 3

0

from math import * def main (): angleInradians= pi/6 sinValue = sin (angleInradians) print (sinValue ) main() 0.49999999999999994 1.0 3.141592653589793 1.3434343

0.49999999999999994

num = 138 print(num / 12) print(num % 100) print(8 + 3 * 7) print(8 * 3 % 7 ) print(8 + 3 / 6 )

1. 11.5 2.38 3.29 4.3 5.8.5

16 - 2 * 5 // 3 + 1

14

Which of the following are not valid variable names? main 15_national_championships X_Y i _main

15_national_championships

2 * 3 ** 2 evaluates to __________. 81 18 12 36

18

Which of the following is not a valid variable name? c0nif3r _underscore 1_var

1_var

What gets printed? x = 4.5 y = 2 print(x//y) 3 2 2.0 21 4

2.0

(16 - 2) * 5 // 3 + 1 24 10 14 13.667

24

from math import * def main (): angleInDegrees = 30 angleInRadians = radians(angleInDegrees ) * 6 print (angleInRadians) main() 0.0 1.3434343 5.565656 3.141592653589793

3.141592653589793

What is max(30, -50, 1, 17, -4)? 17 4 30 1 -50

30

max(3, 2, 5, 6) * min(5, 5, 5) 36 25 0 30

30

24 % 5 is _____ 2 3 0 4 1

4

What is round(3.52)? 5 3.5 4 3 3.5

4

What value is printed when the following statement executes? print(int(53.999)) 54 Nothing is printed. It generates a runtime error. 53 53.999

53

What is the value of x after this code fragment is executed? x = 6 y = x y = y + 1 7 6 5 an error results

6

pow(2, 3) * pow(3, 2)=

72

What is the value of the following expression: 2 ** 2 ** 3 * 3 768 128 12 256

768

2 ** 3 evaluates to 8 8.0 9 9.0

8

2 ** 3.0 evaluates to 8 8.0 9 9.0

8.0

from math import *def main (): angle = pi / 2 angleInDegrees = degrees(angle) print (angleInDegrees)main() 0.0 45.0 90.0 30.0

90.0

Which of the following is a valid variable name? if def And 1TwoThree

And

The # character means that: Python should ignore any remaining characters after # on the line. Python should display the characters after the #. Python should treat the remainder of the line as a string Python converts the string after # into a number

Python should ignore it and any remaining characters on the line

The result coming from one of the following functionsasin, acos, or atan will be an angle that is measured in radians. True False

True

To use the functions sin, cos and tan in Python, you have to convert the angle to radians first. False True

True

Which of the following are valid literals? Check all that apply. True true "Python" 5

True 5 "Python"

Which of the following are valid literals? Check all that apply literal false True _334 False

True, False

What's the output of the following program? print("Welcome",end="?") print("Alex")

Welcome?Alex

Which of the following is a valid variable name? 1 a "a" True

a

Which of the following expressions is equivalent to pow(a, b)? a ** b pow(b, a) a * b a // b

a ** b

Which of the following is not a valid variable name? sumOfAll x_y For and

and

The string value is usually enclosed between ____________________.

double quote only single-quote only. triple quotes only. single quote, double quotes, or triple quotes

Which of the following functions evaluate to 4? int(4.5) int(3.5) round(4.4) 22 // 4

int(4.5) round(4.4)

Which of the following is not a literal? 3.4e2 "Good morning" "Chicago" 2.79 literal 13

literal

x = float(input()) y = float(input()) # compute the average of x and y avg = x + y / 2 print(avg)

logical error

Which of the following display Programming is fun! rint("Programming ", "is", " fun!") print("Programming", "is", "fun", "!") print("Programming", "is", "fun!") print("Programming is fun!")

print("Programming", "is", "fun!") print("Programming is fun!")

TypeErrors are ___________ errors. syntax runtime logical

runtime

When there is a ZeroDivisionError in a program run, there is an _________ error. runtime logical syntax

runtime

import math # compute the square root of a negative input x = input() root = math.sqrt(x) print(root)

runtime error

What is the data type of 'this is an example'? float int char str

str

Missing a matching parenthesis will cause a ___________ error. logical syntax runtime

syntax

# compute the square root of x import math x = float(input()) root = math.sqrt x print root

syntax error

What's the output of the following print statement? x = 5 print("x", "=", x) x=x x=5 x = 5 x = 5

x =5


संबंधित स्टडी सेट्स

Nursing Process Exam 1 Practice Questions

View Set

Ch. 58 Care of Patients with Liver Problems

View Set

Chapter 56: Acute Intracranial Problems

View Set

Chapter 3- Biopsychology Quiz Review

View Set

Chapter 15: Critical Thinking in Nursing Practice

View Set