4. Numbers, Boolean, None, Value and more. Flashcards

1
Q

Data type in Python

A

integer - int
floating-point numbers - float
string - str
boolean - bool

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

Result of a floating-point division (/) is always _________

A

float

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

Result of other operations…

A

float - if either num is float

int - if otherwise

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

True and False first letter must be

A

CAPATILISED

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

How to write an operation for square root?

A

**(decimal/fraction)

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

How ‘and’ works

A

Returns True if both left

and right are true

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

How ‘or’ works

A

Returns True if either the

left or the right is true.

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

How ‘not’ works

A

Returns True if the value

being tested is False

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

None Value represent

A
  • Represent null values or nothingness.

* Not the same as False, or an empty string, or 0

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

To write comment, we need to add ____ infront

A

#

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

Type of comment

A

Block Comments = indented at the same level as the code block

Inline Comments = placed on the same line as a statement

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

a = a + b →

A

a += b

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

a = a * b →

A

a *= b

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

a = a // b →

A

a //= b

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

a = a % b →

A

a %= b

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

Type of value obtained from input() is always

A

str

17
Q

True for int and float

A

!= 0

18
Q

False for str

A

”” #no space!

19
Q

Type of Python output format

A

String format()

F-String

20
Q

How String format () looks

A

y = x.format(*args, **kwargs) ex:

y = “{0} is {1} years old”.format(“Lady Gaga”, 33)

or

name = “Lady Gaga”
age = 33
y = “{0} is {1} years old”.format(name, age)
21
Q

How String format () looks

A

> > > name = ‘Tony’
age = 40
f’{name} is {age} y.o.’

22
Q

Syntax Error

A

Grammatical error.

23
Q

Runtime Error

A

Errors discovered while program is running.

24
Q

Logic Error

A

• Occurs when a program does not perform as intended.

• Python interpreter will not show any error message, but will
produce wrong result.