Wek 4 Flashcards

1
Q

What is a constant?

A

Fixed values such as number, letters are called constants because these numbers do not change

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

What do string constant use?

A

quotes (‘) or double quotes (“)

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

What is a variable?

A

is a named place in the memory where a programmer can store data and later receive the data suing the variable “name”

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

Do programmers get to use choose the names of variables?

A

Yes, they do.

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

What are good names for variables?

A

spam, eggs, spam23, _speed

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

What are bad names for variables?

A

23spam, #sign, var.12

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

Are these distinct variables: spam, Spam, SPAM ?

A

Yes.

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

Can you use reserved words as valuables?

A

No, you cannot.

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

What is this: x = 2

A

An assignment statement

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

How do you call this:

A

x = x + 2 (Assignment with expression)

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

Of what does an assignment statement consist?

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

Can x change its value?

A

Yes, absolutely

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

What is the operator for addition?

A

x

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

What is the Oprator for subtraction?

A

-

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

What is the Operator for multiplication ?

A

*

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

What is the Operator for division?

A

/

17
Q

What is the operator for power?

A

**

18
Q

What is the operator for remainder?

A

%

19
Q
A
20
Q

What are the operator precedence rules?

A
  1. Parenthesis
  2. Exponentiation
  3. Multiplication
  4. Addition
  5. Left to right
21
Q

How is integer division in Python?

A

quite weird

22
Q

99/100

What will come out in Python?

A

0

23
Q

99/100.0

What will come out in Python?

A

0.99

24
Q

What happens if you perform an operation and one number is an integert and the other a floating point?

A

the result is a floating point

25
Q

What does concatenate mean?

A

put together

26
Q

How can you find out the type of sth?

A
27
Q

When you put an integer and a floating point into an expression the result will be…

A

a floating point

28
Q

print float (99)/100

A

0.99

29
Q

Can you concatenate a string and an integer?

A

No, that is not possible

30
Q

How do you find out the type of “sval” ?

A

print type(sval)

31
Q
A
32
Q

What do you use the raw input function for?

A
33
Q

In Python, anything after a # is…

A

ignored

34
Q

HOw can you multiply Hi fiv e times?

A

print “Hi” * 5

35
Q

On what should you base your decision about variables?

A

On what we want to remember

36
Q
A