Python Basic Flashcards

1
Q

Exponent Operator and example

A

**

2**3 = 8

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Modulus/remainder operator and example

A

%

7%5 = 2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Integer division/floored quotient operator and example

A
//
12//5 = 2
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Division operator and example

A

/

12/5=2.4

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Multiplication operator and example

A

*

2*5=10

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Subtraction operator and example

A

-

5-2=3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Addition operator and example

A

+

5+2=7

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the order of operations (also called precedence) of Python math operators?

A
**
%
//
/
*
-
\+
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are expressions?

A

values combined with operators, and they always evaluate down to a single value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are the most common data type in python?

A

integers = -2, 5, 6
Floating-point numbers(float) = 2.44
strings = a, b ,c

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What does it mean?

SyntaxError: EOL while scanning string literal

A

you probably forgot the final single quote character at the end of the string
EOL stands for end of line

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the string concatenation operator?

A

+
‘Bob’ + ‘ ‘ + ‘ Dylan’
Bob Dylan

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What does it mean?

TypeError: can only concatenate str (not “int”) to str

A

‘Bob’ + 25

we cannot use + to concatenate strings and integers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is string replication operator?

A

‘Bob’*5 (this should be a value, it cannot be a string)

‘BobBobBobBobBob’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is an assignment statement?

A

Spam = 25

variable name, an equal sign (called the assignment operator), and the value to be stored

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How to change the value of a variable?

A

by assigning a new value to it

17
Q

What are the variable names rules?

A

It can be only one word with no spaces.
It can use only letters, numbers, and the underscore (_) character.
It can’t begin with a number.

18
Q

different way of naming a value?

A

camelCase
PascalCase
snake_case

19
Q

How to ask for user’s input?

A

myAge = input()

20
Q

How to write a comment in python?

A


or

””” “””

21
Q

How to use print function to put a blank line on the screen?

A

just call print() with nothing in between the parentheses.

22
Q

what value type does input() function return?

A

only string

23
Q

How to convert value type in python?

A

str(42)
int(‘42) , int(age)
float(‘42.5’)

24
Q

function to round a number?

A

round(2.5555, 2)

2.55