Presentation is loading. Please wait.

Presentation is loading. Please wait.

What type of data can a variable hold?

Similar presentations


Presentation on theme: "What type of data can a variable hold?"— Presentation transcript:

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

2 Which of the following *is* a valid variable name?
ninety_nine_balloons ninety nine balloons 99_balloons

3 Which of the following *IS NOT* a string?
“42” ‘42’ 42

4 What would happen if you attempt to assign a value to a variable that does not exist?
Example: some_variable = 235 Nothing happens “some_variable” now holds the value 235 Python generates an error

5 What would happen if you attempt to PRINT a variable that does not exist?
Example: print(foo) Nothing happens PRINT outputs and empty string Python generates an error

6 What is the value of my_var after the following execution sequence?
>>> my_var = my_var + 1 7 8

7 Which of the following are control structures?
FOR IF input() A & B A, B, & C

8 A comment in Python is indicated by a:
Colon (:) Dollar sign ($) Asterisk (*) Pound Sign (#)

9 Which variable is properly named?
MyVariable myVariable my_variable My_Variable My Variable

10 What is the default data type of all user input?
int string float main

11 How do we obtain user input?
print() FOR float()

12 How many times will this loop?
for i in range(7): pass 7 8 6

13 Ask the audience: Why do we use “pass” below?
for i in range(7): pass

14 How much will the variable “i” equal at the end of the loop?
for i in range(8): pass 6 7 8 9

15 What is the value of x after this loop?
for i in range(3): x = i * 2 3 6 8 4

16 What data type holds decimal numbers?
int float char string

17 How many times will the PRINT get called?
for i in range(8): for j in range(7): print("hello") 7 8 42 56

18 Which of the following. IS NOT
Which of the following *IS NOT* a relational operator (used in IF statements) < == != = >=

19 Which Checks Get Passed?
x = 25 if 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 B C D

20 What data type holds whole numbers?
int float char string

21 What is the output? A = ‘this’ B = “that” print(a + b)
Python throws an error this that ‘this’”that” thisthat

22 What does x equal? x = input(“Enter x: “) (we enter: -2 * 3 + 5) -16
‘-2 * 3 + 5’ Python throws an error

23 What is the value of x after the following operation?
3 1

24 What is the result? 4 * 1 // 2 2 2.0 2.5

25 What is the value of x after the following operation?
my_string = “I like lamp” x = my_string[2] I L K like lamp

26 What is the output? print(2 + 3) 2 + 3 2 + 3 = 5 5
Python throws an error

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

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

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

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

31 Are these loops equivalent?
while i <= 9: print(i) i = i + 1 for i in range(11): print i Yes No


Download ppt "What type of data can a variable hold?"

Similar presentations


Ads by Google