Python Coding Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

How would you describe Python?

A

It is a high level programming language

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

What is a variable?

A

Variables are containers for storing data values

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

What is missing from this line of code?

print(“hello world”

A

it is missing a )

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

What is a syntax error?

A

When the code has a spelling mistake or missing punctuation in the code

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

PRINT is an example of what programming technique?

A

Sequence

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

WHILE is an example of what programming technique?

A

Iteration

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

IF ELSE is an example of what programming technique?

A

Selection

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

What does iteration actually mean?

A

Loop

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

name = input (“what is your name”)

Where does the user’s entry get saved?

A

Saved in the variable called name

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

When this code has run, what value does total contain?

number_one = 10

number_two = 4

total = number_one + number_two

A

14

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

When this code has run, what value does total contain?

number_one = “10”

number_two = “4”

total = number_one + number_two

A

104 - as they have “ “ round them they are strings not integers

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

score = 100

What does this line of Python code do?

A

Nothing, it’s a comment

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

What is the syntax error in the code below?

Print (score)

A

Print needs to be in lower case - print (score)

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

Explain why the code below will cause a syntax error.

if age > 12:

print(“Sorry you are too old”)

A

The second line needs to be indented as it follows an if statement

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

What do you use if you have more than one IF command?

A

elif would be used which stands for ‘else if’

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

What other errors can you get apart from a syntax error?

A

Logic or run-time error