Python Flashcards

1
Q

What is a string variable?

A

A variable that contains words.

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

How do you change a variable to an integer?

A

You put ‘variable = int(variable)’

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

How do you write a conditional statement?

A

You use an if statement

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

What does ‘len’ do?

A

It tells you how many characters there are in the variable

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

How do you print something?

A

You use the function ‘print’

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

How do you combine if and else?

A

Elif

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

How do you get someone to input text?

A

You use the ‘input’ function

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

What are the three types of variable?

A

String, Integer and Float

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

What is an integer?

A

A number that doesn’t involve decimals.

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

What is a float?

A

A number that does involve decimals.

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

How do you start a new line?

A

Write \n.

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

What is a syntax error?

A

An error in the code which means that the computer cannot carry out any of the code.

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

What does ().upper do?

A

It makes all the characters in the string upper case.

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

What are the comparations you can make in an if statement?

A

<=, >=, ==, !=

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

How do you repeat actions in Python?

A
You can say
while this is true:
(closed loop)
or
for x in this array:
(open loop)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly