Computer Programming: Python - Module 1 (Terms)

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

concatenation operator

+ (plus) sign, when applied to two strings It simply concatenates (glues) two strings into one. Of course, like its arithmetic sibling, it can be used more than once in one expression, and in such a context it behaves according to left-sided binding.

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

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 % y x = x % y y = y % x print(y)

1

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

1*1*1

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

17.5

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

2 1

The value twenty point twelve times ten raised to the power of eight should be written as:

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)

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)

333333

scientific notation

3E8=300000000 the exponent (the value after the E) has to be an integer; the base (the value in front of the E) may be an integer.

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)

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/y y=y/x print(y)

8.0

comment

A remark inserted into the program, which is omitted at runtime

octal representation

If an integer number is preceded by an 0O or 0o prefix (zero-o), it will be treated as an octal value. This means that the number must contain digits taken from the [0..7] range only. 0o123 is an octal number with a (decimal) value equal to 83.

binding

Most of Python's operators have left-sided binding, which means that the calculation of the expression is conducted from left to right. exponentiation operator uses right-sided binding.

the arguments

Python functions, on the other hand, are more versatile. Depending on the individual needs, they may accept any number of arguments - as many as necessary to perform their tasks. Note: any number includes zero - some Python functions don't need any argument.

hierarchy of priorities

Python precisely defines the priorities of all operators, and assumes that operators of a larger (higher) priority perform their operations before the operators of a lower priority

hexadecimal numbers

Such numbers should be preceded by the prefix 0x or 0X (zero-x). 0x123 is a hexadecimal number with a (decimal) value equal to 291.

Boolean value

The name comes from George Boole (1815-1864), the author of the fundamental work, The Laws of Thought, which contains the definition of Boolean algebra - a part of algebra which makes use of only two distinct values: true and false, denoted as 1 and 0.

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

True

operators

a symbol of the programming language, which is able to operate on the values. 2**3 (2³) 2*3 (2x3) 6/2 (6/2) // (integer divisional operator-results are always rounded)rounding always goes to the lesser integer. % (modulo-remainder left after the integer division.) + (plus) - (minus)

The print() function can output values of:

any number of arguments (including zero)

Unary and Binary Operators

binary operators like the addition, multiplication and division operators. unary + operator. You can use it like this: print(+2) operator preserves the sign

The \n digraph forces the print() function to:

break the output line

Python variable

containers that can be varied in (almost) any way What does every Python variable have? a name; a value (the content of the container)

replication operator

he * (asterisk) sign, when applied to a string and number (or a number and string It replicates the string the same number of times specified by the number.

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 or some values (e.g., the square root of a value or the length of a given text); this is what makes Python's functions the relatives of mathematical concepts.

literal

is data whose values are determined by the literal itself. 123 is a literal, and c is not You use literals to encode data and to put them into your code.

The result of the following division: 1 / 1

is equal to 1.0

The 0o prefix means that the number after it is denoted as:

octal

The ** operator:

performs exponentiation

integer

positional numeral system that is, those which are devoid of the fractional part; 4 is an integer number 4.0 is a floating-point number

floating-point

positional numeral system; numbers (or simply floats), that contain (or are able to contain) the fractional part. 4 is an integer number 4.0 is a floating-point number

int()

takes one argument (a string) and tries to convert it into an integer; if it fails, the whole program will fail too

float()

takes one argument and tries to convert it into a float (the rest is the same)

The meaning of the keyword parameter is determined by:

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//y y=y//x print(y)

the code will cause a runtime error

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

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

string

the string is delimited with quotes - in fact, the quotes make the string - they cut out a part of the code and assign a different meaning to it. Strings are used when you need to process text (like names of all kinds, addresses, novels, etc.), not numbers. An empty string still remains a string.

binary system

the system computers use for storing numbers, and that they can perform any operation upon them

keywords

words that play a very special role in every Python program The meaning of the reserved word is predefined, and mustn't be changed in any way.


Set pelajaran terkait

AP Chemistry Chapter 10 Test FRQ

View Set

Med Surg II - Chapter 31 - Care of Patients with Infectious Respiratory Problems

View Set

Writing a business plan - chapter 6

View Set

E-business Management- Ch.7 Social, Mobile, and Local Marketing

View Set