Python Programming Flashcards

1
Q

What is an algorithm?

A

An algorithm is a step-by-step procedure, which defines a set of instructions to be executed in a certain order to get the desired output

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

What is the purpose of a python algorithm?

A

Python algorithms provide a detailed set of instructions by which you can process data for a specific purpose.

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

What are variables and what are some types?

A

They are containers for storing values. Some types include text and number variables.

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

What are integers?

A

Whole numbers.

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

What is ‘float’ in Python?

A

A number that isn’t whole (eg - 2.3).

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

What are the rules of text variables?

A

Must begin with a letter

Contain only letters and numbers or underscores but no other symbols

Must not be commands, e.g. PRINT is not a valid variable

Must not have any spaces

Cannot start with a number

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

What does the ‘print’ command do?

A

Prints a specified message onto your screen.

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

How do you add things together in Python?

A

Use +.

Example: 786 + 110

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

How do you subtract in Python?

A

Use -.

Example: 14 - 12

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

How do you multiply things together in Python?

A

Use *.

Example: 5 * 124000

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

How do you divide in Python?

A

Use /.

Example: 786 / 110

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

How do you write powers?

A

Use the command pow(number, number)

Example: pow(5, 622)

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

How do you use square root and pi and Python?

A

First, you must write the code import math. Then you can write math.sqrt or math.pi

Example: math.sqrt(100)

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

What is the greater than sign in Python?

A

>

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

What is the less than sign in Python?

A

<

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

What is the greater than or equal to sign in Python?

A

> =

17
Q

What is the less than or equal to sign in Python?

A

<=

18
Q

What is the equal to sign in Python?

A

==

19
Q

What is the not equal to sign in Python?

A

!=

20
Q

What does the if statement mean in Python?

A

If a condition if true, then do this.

21
Q

What does the elif statement do?

A

The elif keyword is Python’s way of saying “if the previous conditions were not true, then try this condition”

22
Q

What does the else statement do?

A

The else keyword catches anything not caught by the previous conditions.