2: Variables, Expressions, Statements Flashcards

0
Q

What is a type?

A

Each separate value can be categorized under one of these. Some of these categories include: integer (numbers), float (numbers with decimal points) and string (sequence of letters)

Note: strings must be contained by quotation marks.

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

What is a value?

A

One of the basic things a program works with, such as a letter or a number.

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

What does Python do with commas in large integers?

A

> > > print 1,000,000
100

Python interprets commas as a seperation between a sequence of integers, which it then prints with spaces in between.

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

What is a variable?

A

A name that refers to a value.

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

What is an assignment statement?

A

This creates new variables and gives them values.

EX of three various ________:

> > > message= “let’s do something”
N = 17
pi = 3.14159265

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

What is a statement?

A

A unit of code that the Python interpreter can execute.

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

What is an operator?

A

Special symbols that represent computations like addition and multiplication.

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

What are operands?

A

The values the operator is applied to.

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

What is floor division?

A

An operation that is performed between two integers this producing a third integer as the result.

Ex. 9/10 = 0
8/3 = 2

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

What is floating point division?

A

A division function where at least one floating point number is involved, thus producing an answer as a float or number including a decimal point.

Ex. 59/60.0 = .98333333

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

What is an expression?

A

A combination of values, variables, and operators. In addition, a value or a variable is considered an expression all by itself.

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

What are the rules of precedence? Think of algebra.

A

PEMDAS

Parentheses
Exponentation
Multiplication or Division (left to right)
Addition or Subtraction (left to right)

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

What is the modulus operator?

A

An equation that works on integers and yields the remainder when the first operands is divided by the second. In Python, the operator for this equation is %

> > > quotient = 7/3
print quotient
2

> > > remainder = 7%3
print remainder
1

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

What is concatenation?

A

The joining of strings by linking them end to end.

> > > first = ‘100’
second = ‘150’
print first + second
100150

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

raw_input

A

A built in function within Python which when the function is called, the program stops and waits for the user to type something.

Then, once the user presses return or enter, the program returns what the user typed as a string

> > > input = raw_input ()
Hi there computer
print input
Hi there computer

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

/n

A

A prompt which represents a new line. It is a special character that causes a line break.

16
Q

#

A

A symbol which prompts Python to ignore anything added afterwards. This symbol is a way for programmers to add notes or comments to their program.

You can add comments on a line by itself or after your line of code. Everything from the # to the end of the line is ignored.

17
Q

‘Use before def’

A

Common bug: You are trying to use a variable before you have assigned it a value

Remember variables are case sensitive

Case does not = case