Unit 1 - Lesson 1 - Programming Basics Flashcards

1
Q

What is a String?

A

A series of characters inside quote marks.

Strings can contain single character, a word, a phrase, a sentence, or entire paragraphs

For example:

“Hello World”

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

What does the computer do with comments added to a program?

A

The computer passes over comments added to a program without turning them into machine code.

In other words, the computer will ignore the comments.

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

Explain the syntax of a print command. What goes in the brackets?

A

The syntax of the print command begins with the word print in lower case Then there are brackets. The content that is to be displayed goes inside the brackets.

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

Describe what happens when you run a python program?

A

When you run a python program, the lines of the program are converted into machine code one by one, and immediately executed.

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

What does IDE stand for?

A

IDE stands for integrated development environment.

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

What is the purpose of IDE software?

A

IDE software allows you to save your program.

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

What features does an IDE have that you would not find in an ordinary word processor?

A

An IDE lets you type up your program and save it, runs your code, gives you guidance about errors in your code, and uses colour to show the different features of the code.

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

While using an IDLE, where will you see the results of the programs?

A

The results will be shown in the Shell window.

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

An IDLE has two different windows, what are their names?

A

IDLE has two windows called Python Shell and Program Editor:

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

What is the name for code that represents a data value?

A

A variable

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

What is the command to assign the value 19.99 to the variable ticket_cost?

A

ticket_cost = 19.99

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

What is the command to output the value stored in the variable ticket_cost?

A

print(ticket_cost)

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

What is wrong with the following variable name:

Character Name

A

Character Name is bad as it includes a space. When a variable name consists out of more than one word the words need to be separated by an underscore and not a space

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

What is wrong with the following variable name:

5star

A

5star is bad because it starts with a number. Variable names cannot start with a number as this will produce an syntax error.

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

What is wrong with the following variable name:

myvariable

A

myvariable is not a good variable name, because the two words “my” and “variable” are not separated by an underscore, which makes it difficult to read.

myvariable is also not very meaningful, as it doesn’t tell us much about the kind of values that will be stored in it.

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

What is wrong with the following variable name:

Star*rating

A

Star*rating is bad because it includes a symbol. Variable names cannot include symbols, because this will produce a syntax error.

17
Q

An input command includes a prompt. What is the purpose of a prompt?

A

A prompt tells the user what to type in.

18
Q

If you enter an input command without a variable, what happens to the user input?

A

If you enter an input command without a variable, the user input won’t be stored, so the content will be lost.

19
Q

If you enter an input command with a variable, what happens to the user input?

A

If you enter an input command with a variable, the user input will be stored in an area of memory given the name of the variable

20
Q

The following python program has an error in it. What is the error?

print(“User Name”)
print(user_name)
user_name = input(“Enter your name”)

A

print(“User Name”)

This program will produce an error as the program is attempting to print the value of the variable user_name before the variable has been declared.

21
Q
A