Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "What type of data can a variable hold? A: Numbers B: Strings C: A & B D: Practically everything."— 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? A.ninety_nine_balloons B.ninety nine balloons C.99_balloons

3 Which of the following *IS NOT* a string? A.42 B.42 C.42

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

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

6 What is the value of my_var after the following execution sequence? >>> my_var = 0 >>> my_var = 7 >>> my_var = my_var + 1 A.7 B.8 C.0

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

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

9 Which variable is properly named? A.MyVariable B.myVariable C.my_variable D.My_Variable E.My Variable

10 What is the default data type of all user input? A.int B.string C.float D.main

11 How do we obtain user input? A.input() B.print() C.FOR D.float()

12 How many times will this loop? for i in range(7): pass A.0 B.7 C.8 D.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 A.0 B.6 C.7 D.8 E.9

15 What is the value of x after this loop? x = 1 for i in range(3): x = i * 2 A.0 B.3 C.6 D.8 E.4

16 What data type holds decimal numbers? A.int B.float C.char D.string

17 How many times will the PRINT get called? for i in range(8): for j in range(7): print("hello") A.0 B.7 C.8 D.42 E.56

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

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) AnswerCheck 1Check 2Check 3Check 4 AYesNo Yes B No C YesNoYes D

20 What data type holds whole numbers? A.int B.float C.char D.string

21 What is the output? A = this B = that print(a + b) A.Python throws an error B.this that C.thisthat D.thisthat

22 What does x equal? x = input(Enter x: ) (we enter: -2 * 3 + 5) A.-16 B.-1 C.-2 * D.Python throws an error

23 What is the value of x after the following operation? x = 10 // 3 A.0 B C.3 D.1

24 What is the result? 4 * 1 // 2 A. 2 B. 0 C.2.0 D.2.5

25 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

26 What is the output? print(2 + 3) A B = 5 C.5 D.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 \ ) A.Cannot divide by zero! B.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") else: print("Fa") A.Do B.Re C.Mi D.Fa

29 What Is the Output? guess = 25 if guess < 100: if guess > 50: print("Do") elif guess > 25: print("Re") else: print("Mi") else: print("Fa") A.Do B.Re C.Mi D.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. A.True B.False

31 Are these loops equivalent? i = 0 while i <= 9: print(i) i = i for i in range(11): print i A.Yes B.No


Download ppt "What type of data can a variable hold? A: Numbers B: Strings C: A & B D: Practically everything."

Similar presentations


Ads by Google