what type of data can a variable hold? a: numbers b: strings c: a & b d: practically everything

31
What type of data can a variable hold? • A: Numbers • B: Strings • C: A & B • D: Practically everything

Upload: victoria-bennett

Post on 26-Mar-2015

221 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: What type of data can a variable hold? A: Numbers B: Strings C: A & B D: Practically everything

What type of data can a variable hold?

• A: Numbers• B: Strings• C: A & B• D: Practically everything

Page 2: What type of data can a variable hold? A: Numbers B: Strings C: A & B D: Practically everything

Which of the following *is* a valid variable name?

A.ninety_nine_balloonsB.ninety nine balloonsC.99_balloons

Page 3: What type of data can a variable hold? A: Numbers B: Strings C: A & B D: Practically everything

Which of the following *IS NOT* a string?

A.“42”B.‘42’C.42

Page 4: What type of data can a variable hold? A: Numbers B: Strings C: A & B D: Practically everything

What would happen if you attempt to assign a value to a variable that does

not exist?

Example: some_variable = 235

A.Nothing happensB.“some_variable” now holds the value 235C.Python generates an error

Page 5: What type of data can a variable hold? A: Numbers B: Strings C: A & B D: Practically everything

What would happen if you attempt to PRINT a variable that does not exist?

Example: print(foo)

A.Nothing happensB.PRINT outputs and empty stringC.Python generates an error

Page 6: What type of data can a variable hold? A: Numbers B: Strings C: A & B D: Practically everything

What is the value of my_var after the following execution sequence?

>>> my_var = 0

>>> my_var = 7

>>> my_var = my_var + 1

A.7B.8C.0

Page 7: What type of data can a variable hold? A: Numbers B: Strings C: A & B D: Practically everything

Which of the following are control structures?

A. FORB. IFC. input()D. A & BE. A, B, & C

Page 8: What type of data can a variable hold? A: Numbers B: Strings C: A & B D: Practically everything

A comment in Python is indicated by a:

A.Colon (:)

B.Dollar sign ($)

C.Asterisk (*)

D.Pound Sign (#)

Page 9: What type of data can a variable hold? A: Numbers B: Strings C: A & B D: Practically everything

Which variable is properly named?

A.MyVariableB.myVariableC.my_variableD.My_VariableE.My Variable

Page 10: What type of data can a variable hold? A: Numbers B: Strings C: A & B D: Practically everything

What is the default data type of all user input?

A.int

B.string

C.float

D.main

Page 11: What type of data can a variable hold? A: Numbers B: Strings C: A & B D: Practically everything

How do we obtain user input?

A.input()

B.print()

C.FOR

D.float()

Page 12: What type of data can a variable hold? A: Numbers B: Strings C: A & B D: Practically everything

How many times will this loop?

for i in range(7):

pass

A.0

B.7

C.8

D.6

Page 13: What type of data can a variable hold? A: Numbers B: Strings C: A & B D: Practically everything

Ask the audience: Why do we use “pass” below?

for i in range(7):

pass

Page 14: What type of data can a variable hold? A: Numbers B: Strings C: A & B D: Practically everything

How much will the variable “i” equal at the end of the loop?

for i in range(8):

pass

A.0

B.6

C.7

D.8

E.9

Page 15: What type of data can a variable hold? A: Numbers B: Strings C: A & B D: Practically everything

What is the value of x after this loop?

x = 1for i in range(3): x = i * 2

A.0B.3C.6D.8E.4

Page 16: What type of data can a variable hold? A: Numbers B: Strings C: A & B D: Practically everything

What data type holds decimal numbers?

A.int

B.float

C.char

D.string

Page 17: What type of data can a variable hold? A: Numbers B: Strings C: A & B D: Practically everything

How many times will the PRINT get called?

for i in range(8): for j in range(7): print("hello")

A.0B.7C.8D.42E.56

Page 18: What type of data can a variable hold? A: Numbers B: Strings C: A & B D: Practically everything

Which of the following *IS NOT* a relational operator (used in IF

statements)

A.<

B.==

C.!=

D.=

E.>=

Page 19: What type of data can a variable hold? A: Numbers B: Strings C: A & B D: Practically everything

Which Checks Get Passed?x = 25if x == 25: print("passed 1st check")if x > 25: print("passed 2nd check")if x < 25: print("passed 3rd check")if x > 1: print("passed 4th check“)

Answer Check 1 Check 2 Check 3 Check 4

A Yes No No Yes

B Yes No No No

C No Yes No Yes

D Yes Yes Yes Yes

Page 20: What type of data can a variable hold? A: Numbers B: Strings C: A & B D: Practically everything

What data type holds whole numbers?

A.int

B.float

C.char

D.string

Page 21: What type of data can a variable hold? A: Numbers B: Strings C: A & B D: Practically everything

What is the output?

A = ‘this’B = “that”print(a + b)

A.Python throws an errorB.this thatC.‘this’”that”D.thisthat

Page 22: What type of data can a variable hold? A: Numbers B: Strings C: A & B D: Practically everything

What does x equal?

x = input(“Enter x: “)

(we enter: -2 * 3 + 5)

A.-16

B.-1

C.‘-2 * 3 + 5’

D.Python throws an error

Page 23: What type of data can a variable hold? A: Numbers B: Strings C: A & B D: Practically everything

What is the value of x after the following operation?

x = 10 // 3

A.0

B.3.333333333

C.3

D.1

Page 24: What type of data can a variable hold? A: Numbers B: Strings C: A & B D: Practically everything

What is the result?

4 * 1 // 2

A. 2

B. 0

C.2.0

D.2.5

Page 25: What type of data can a variable hold? A: Numbers B: Strings C: A & B D: Practically everything

What is the value of x after the following operation?

my_string = “I like lamp”

x = my_string[2]

A.I

B.L

C.K

D.like lamp

Page 26: What type of data can a variable hold? A: Numbers B: Strings C: A & B D: Practically everything

What is the output?

print(2 + 3)

A.2 + 3

B.2 + 3 = 5

C.5

D.Python throws an error

Page 27: What type of data can a variable hold? A: Numbers B: Strings C: A & B D: Practically everything

What Is the Output?numerator = 4denominator = 2if denominator == 0: print("Cannot divide by zero!")else: print( \ numerator, \ "/", \ denominator, \ "=", \ numerator / denominator \ )

A. Cannot divide by zero!B. 2.0

Page 28: What type of data can a variable hold? A: Numbers B: Strings C: A & B D: Practically everything

What Is the Output?guess = 35if guess < 100: if guess > 50: print("Do") elif guess > 25: print("Re") else: print("Mi")else: print("Fa")

A. DoB. ReC. MiD. Fa

Page 29: What type of data can a variable hold? A: Numbers B: Strings C: A & B D: Practically everything

What Is the Output?guess = 25if guess < 100: if guess > 50: print("Do") elif guess > 25: print("Re") else: print("Mi")else: print("Fa")

A. DoB. ReC. MiD. Fa

Page 30: What type of data can a variable hold? A: Numbers B: Strings C: A & B D: Practically everything

Quiz Question

The main difference between FOR and WHILE loops is that we usually know the exact number of iterations in a FOR loop.

A.True

B.False

Page 31: What type of data can a variable hold? A: Numbers B: Strings C: A & B D: Practically everything

Are these loops equivalent?

i = 0while i <= 9: print(i) i = i + 1----------------for i in range(11): print i

A.YesB.No