2. Python was created by Guido Van Rossum
4. Which of the following is NOT an operator?
5. The output of the following code is the integer 2.
6. Name the two subroutines/procedures (these are called functions in Python) in the code below:
7. Why will the following code not run?
8. The following program will not run correctly. Can you predict what the output will be and explain why?
9. What is the output of the following program?
10. What do you need to change in the following program to get it to print the total to pay with the discount applied?
11. Will the following code run correctly?
12. The following is another way of applying discount to a set price: by using a formula for discount, which is a percentage.
a) In the example below, if the price entered was '100', what would the output (total_to_pay) be?
b) What % discount is being
13. What is the following code snippet doing?
14. Sorting is a very important feature of programming. For example, when you load your friends list on facebook, they are often presented ALPHABETICALLY, which is an example of a sort. Sort the following numbers from smallest to largest:
0,3,1,5,7
0,1,3,5,7
7,1,3,5,2
1,3,5,7,0
15. A computer isn't as clever a human! If you gave it a sequence of numbers to sort, it wouldn't be able to just 'look' and do it! It would have to follow an algorithm. What is an algorithm?
16. 'Searching' is another feature that is very important in programming. Almost all programs (think of facebook, instagram, google!) have some sort of 'searching' going on. When it comes to searching, programmers should be interested in ...
17. How would you describe a linear search?
18. If you were given the following list of numbers, and the computer was given the task of searching for the number '6', would it be better to use a Linear or Binary Search?
1,2,3,4,5,6,7,8,9,10,11
Binary search, because in this case it would jump straight to the mid point
Binary search, because Binary means 2 and 2 is more than 1
Binary search, because it would start at 10 and work back to 5 much quicker
Linear search, because it would start at 1, and reach 5 quite quickly
19. In a Binary search: The middle element is looked to check if it is greater than or less than the value to be searched. If the element we are looking for is 55, what would the search be next reduced to?
20. The following program seeks to find the speed of a runner. Can you spot the error?
21. In the following code, what will the output be if you change line 8 to: if budget <=99:
def cars():
#Change the budget to over 5000 in order to display the expensive cars
#Add a few more cars to each list
expensive_cars=["Mercedes","Audi","BMW"]
cheap_cars=["Skoda","Maruthi","Nano"]
budget=int(input("How much can you spend on a car?"))
if budget>=2000:
print("Here are some cars you could consider",expensive_cars)
else:
print("You may want to check out these brands:",cheap_cars)
cars()
cars()
It will print the list of expensive cars, but this is a logic error, as it should print the cheap cars
It will print the list of expensive cars and the cheap cars (at the same time)
It will print the list of cheap cars, and this is correct
It will not run at all, because the budget has to be greater than a certain amount
22. Point out where parameter passing is occurring in the below program?
23. Note that it is possible to assign multiple variables values in one single line. For example x,y=0,2, gives x the value 0 and y the value 2.
What is the output of the following program?
24. What is the output of the following code?
25. What is the following code doing?
26. This is an A Level question: Can you guess what the following program is doing?
27. The following code uses if statements and the 'or' command. What is the output if the user enters "3333"?
28. If the inputs are 3 and 2, what will the output be?
29. In the following program, the user is asked to enter their gender. One user enters "Mail" instead of "Male" and another user enters "Feehmayle" instead of "Female". What is the process, beginning with V, that ensure
30. The following code shows validation in place so that the user cannot enter invalid values. a) Where are the valid options stored in this example? b) What type of programming construct has been used to create this validation in line 9 and 11.
31. What is one of the disadvantages of a Binary Search?
32. In a linear search, the list has to be sorted.
33. What is the != in python?
34. Binary search algorithms are examples of ...
35. In the following example, validation has been considered (to some extent).
36. The output for the following code will be: 36
37. Gmail and Facebook have built in validation into their sign up forms. An example of validation is that you cannot enter an invalid email address.
38. The following is a program written in the wonderful language of C. Can you guess what it is doing?
39. Here is another C program. You may have never programmed in C, but can you guess what is output?
40. Python and Java are both low level programming langauges