190 likes | 199 Views
This article covers topics such as integer division, modulus, Boolean logic, data types, lists, and functions in Python programming. It provides clear explanations and examples to help beginners understand these concepts.
E N D
What is 13 DIV 3 where DIV is integer division? • 2 • 3 • 4 • 5
What is 13 MOD 3 where MOS is the modulus (remainder)? • 1 • 2 • 3 • 4
If A=1 and B=3 then: A<B is false A<=B is true A>B is true A==B is true
Which of these is true of the Boolean AND operator? • Returns true when a pair of expressions are true otherwise returns false • Returns true when either of a pair of expressions are true • Returns true when an expression is false, otherwise returns false. • Always returns false under all circumstances
What data types would you use to represent a car registration number?
What data types would you use to represent the height of a person?
What is the value of c given the following? A=5 B=7 if A < B: print (“x”) elif A > B: print (“y”) else: print (“z”)
What is the value of c given the following? a = 8 b = 7 c = a + b
What sequence of numbers is output give the following? count = 2 while (count < 21): print(count) count = count + 4
Given the following list what value is at index position month[2] (note index zero is the first element)? month=[“January", “April", “June", “August", “December”]
Given the following list what index position is element “December”(note index zero is the first element)? month=[“January", “April", “June", “August", “December”]
Given the following list what index position is element 5 at (note index zero is the first element)? a = [ [1, 2, 3],\ [4, 5, 6],\ [7, 8, 9]]
Given the following list what value is at index position a[0][2] (note index zero is the first element)? a = [ [1, 2, 3],\ [4, 5, 6],\ [7, 8, 9]]
How many parameters does the following function have? add(x,y): total=x+y returntotal
Why is the following not a function? sqaure(x) x_sqaure=x*x
What is a global variable? • A variable that can never be changed • Avariable that can be used anywhere in a program • Avariable that can only be accessed within a function • A variable that can never be accessed
Given the code below what is output composer=“Beethoven” print(composer[2])
C • A • B • A • C • A • B • A • B • A • D • D • A • C • B • A • B • B