Module 2

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

Left‑sided binding determines that the result of the following expression 1 // 2 * 3 is equal to: 0.0 4.5 0 0.16666666666666666

0

What is the output of the following snippet if the user enters two lines containing 11 and 4 respectively? x=int(input())y=int(input())x = x % yx = x % yy = y % xprint(y) 3 2 1 4

1

What is the output of the following snippet? z = y = x = 1print(x,y,z,sep='*') 1 1 1 x y z 1*1*1 x*y*z

1*1*1

What is the output of the following snippet? x = 1 / 2 + 3 // 3 + 4 ** 2print(x) 17 17.5 8.5 8

17.5

What is the output of the following snippet? x=1y=2z=xx=yy=zprint(x,y) 1 2 2 1 1 1 2 2

2 1

The value twenty point twelve times ten raised to the power of eight should be written as: 20E12.8 20.12E8 20.12*10^8 20.12E8.0

20.12E8

What is the output of the following snippet if the user enters two lines containing 2 and 4 respectively? x=input()y=input()print(x+y) 6 24 4 2

24

What is the output of the following snippet if the user enters two lines containing 3 and 6 respectively? x=input()y=int(input())print(x*y) 36 18 333333 666

333333

What is the output of the following snippet if the user enters two lines containing 2 and 4 respectively? x=int(input())y=int(input())print(x+y) 4 2 24 6

6

What is the output of the following piece of code if the user enters two lines containing 2 and 4 respectively? x=int(input())y=int(input())x=x/yy=y/xprint(y) the code will cause a runtime error 8.0 4.0 2.0

8.0

Literal

A literal is data whose values are determined by the literal itself.

operator

An operator is a symbol of the programming language, which is able to operate on the values.

Boolean values

Boolean values are the two constant objects True and False used to represent truth values (in numeric contexts 1 is True, while 0 is False.

input function

The input() function is able to read data entered by the user and to return the same data to the running program.

One of the following variables' names is illegal - which one? true tRUE True TRUE

True

reserved keywords

['False', 'None', 'True', 'and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield']

A 'keyword' is a word that (select 2): a. is the most important word in the whole program b. cannot be used as a function name c. cannot be used as a variable name

a and c

What does every Python variable have?

a name; a value (the content of the container)

The most important difference between integer and floating-point numbers lies in the fact that:a. they are stored differently in the computer memoryb. they cannot be used simultaneouslyc. integers cannot be literals, while floats can

a. they are stored differently in the computer memory

The print() function can output values of: any number of arguments (excluding zero) just one argument any number of arguments (including zero) not more than five arguments

any number of arguments (including zero)

The '0x' prefix means that the number after it is denoted as:a. an octalb. a hexadecimalc. a decimal

b. a hexadecimal

A value returned by the 'input()' function is:a. a floatb. a stringc. an integer

b. a string

The '//' operator:a. performs regular divisionb. performs integer divisionc. does not exist

b. performs integer division

The \n digraph forces the print() function to: output exactly two characters: \ and n duplicate the character next to the digraph stop its execution break the output line

break the output line

The 'escape character' owes its name to the fact that it:a. cannot be caught due to its high speedb. escapes from source files into the computer memoryc. changes the meaning of the character next to it

c. changes the meaning of the character next to it

Right-sided binding means that the following expression:'1 * 2 * 3"will be evaluated:a. in random orderb. from left to rightc. from right to left

c. from right to left

The result of the following addition '123 + 0.0':a. cannot be evaluatedb. is equal to '123'c. is equal to '123.0'

c. is equal to '123.0'

The meaning of the 'positional parameter' is determined by its:a. appearanceb. namec. position

c. position

Only one of the following statements is TRUE - which one?a. neither statement can be evaluated b. addition precedes multiplication c.multiplication precedes addition

c.multiplication precedes addition

A function is a separate part of the computer code able to:

cause some effect (e.g., send text to the terminal, create a file, draw an image, play a sound, etc.); this is something completely unheard of in the world of mathematics; evaluate a value (e.g., the square root of a value or the length of a given text) and return it as the function's result; this is what makes Python functions the relatives of mathematical concepts.

You can also use ___________________________ to modify values assigned to variables, e.g., var += 1, or var /= 5 * 2. (2.1.4.8)

compound assignment operators (shortcut operators)

A / (slash) sign is a ________________ operator.

divisional

newline

empty line

A ** (double asterisk) sign is an ____________________ operator.

exponentiation

The result produced by the division operator is always a __________,

float

Difference between integer and float

floats can contain fractionals/decimals

A // (double slash) sign is an _________________ operator.

integer divisional

the numbers handled by modern computers are of two types:

integers, that is, those which are devoid of the fractional part; and floating-point numbers (or simply floats), that contain (or are able to contain) the fractional part.

The result of the following division: 1 / 1 is equal to 1 cannot be evaluated cannot be predicted is equal to 1.0

is equal to 1.0

A // (double slash) sign is an integer divisional operator. It differs from the standard / operator in two details:

its result lacks the fractional part - it's absent (for integers), or is always equal to zero (for floats); this means that the results are always rounded; it conforms to the integer vs. float rule.

What does \n do in the print statement?

makes a newline

An * (asterisk) sign is a __________________ operator.

multiplication

The 0o prefix means that the number after it is denoted as: decimal binary octal hexadecimal

octal

The ** operator: performs exponentiation performs duplicated multiplication does not exist performs floating-point multiplication

performs exponentiation

The result clearly shows that the exponentiation operator uses _______________________________

right-sided binding.

the result of the input() function is a __________

string.

The meaning of the keyword parameter is determined by: its position within the argument list its value its connection with existing variables the argument's name specified along with its value

the argument's name specified along with its value

What is the output of the following snippet if the user enters two lines containing 2 and 4 respectively? x=int(input())y=int(input())x=x//yy=y//xprint(y) 2.0 the code will cause a runtime error 4.0 8.0

the code will cause a runtime error

Variable Rules

the name of the variable must be composed of upper-case or lower-case letters, digits, and the character _ (underscore) the name of the variable must begin with a letter; the underscore character is a letter; upper- and lower-case letters are treated as different (a little differently than in the real world - Alice and ALICE are the same first names, but in Python they are two different variable names, and consequently, two different variables); the name of the variable must not be any of Python's reserved words (the keywords - we'll explain more about this soon).

Only one of the following statements is false - which one? multiplication precedes addition the result of the / operator is always an integer value the right argument of the % operator cannot be zero the ** operator uses right sided binding

the result of the / operator is always an integer value

What is the output of the following snippet? x = 2 + 3 * 5.print(X) the snippet will cause an execution error 17 17.0 25.0

the snippet will cause an execution error


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

American Government: Types of Governments

View Set

4 - Life Insurance Policies - Provisions, Options and Riders - Exam 1

View Set

Interaction Between People and Their Environment

View Set

Chapter 10 Quiz, Sociology #4 Chapter 10, Sociology Chapter 8, ch 18, Sociology Chapter 10, Chapter 8: Section Quiz, Sociology Ch. 14, Sociology ch 11, Sociology ch 11, Sociology Final, Sociology 100 #3, sociology ch. 12 questions, Ch. 12 Sociology s...

View Set

Pearson Literature 10, Unit 2, Part 2

View Set

Chapter 5: Nevada Statutes and Regulations Common to All Lines

View Set