Python Basics Flashcards

1
Q

Start a new line (force return)

A

/n

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

Function to ask for user input

A

var = raw_input( )

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

Order of Operations

A

( ), Exponent, * / %, + - (Then evaluate left to right)

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

Reserved Words 1

A

assert, def, elif, from, lambda, return, try, break, global, import

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

Reserved Words 2

A

del, is, for, while, except, if, not

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

Reserved Words 3

A

continue, in, print, yield, or, else, raise, exec, class, and, finally, pass

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

statement

A

unit of code that can be executed

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

What is the function that tells what TYPE a variable is?

A

type(X) Will be a str, int or float

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

When expecting a number from prompt input what is the function used to make sure it is a whole number?

A

int(x)

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

How do you start a comment line?

A

This is a comment line with a hashtag.

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

Define Boolean expressions

A

Comparison results that evaluate to True or False.

Used to control program flow.

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

What is the boolean operator that checks if both statements are True?

A

and (only true if BOTH evaluate to true)

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

What are the Comparison Operators

A

< , , >=, ==, !=

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

Boolean operator to check that at least one statement is true

A

or (evaluates to true if at least ONE is true)

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

What does the boolean operator NOT do?

A

Negates an expression. Return False for true statements and True for false statements.

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

What are the rules for naming variables?

A

Must start with a letter or underscore. Case sensitive. Use mnemonic names to reduce the need for comments.