Python Skill Builder

Python is a jackknife language that can be used for shell scripts, desktop apps, websites, AI. You don’t need to become an expert to use it. Knowing even a little can help you solve problems.

Check where you are at with your Python knowledge using this fun 20 question test. You won’t get any immediate rewards but you will be a better person for it 🙂

1. How can you output value 20 from the following tuple:

sampleTuple = ("Orange", [10, 20, 30], (5, 15, 25))
 
 
 
 

2. What is the output of the following code:

sampleTuple = (100, 200, 300, 400, 500)
print(sampleTuple[-2])
print(sampleTuple[-4:-1])
 
 
 

3. What is the type of the following variable:

sampleTuple = ("Apples")
print(type(sampleTuple))
 
 
 
 

4. In Python, Dictionaries are immutable

 
 

5. What is the max length of a Python string?

 

 
 
 

6. What is the output:

print('[%c]' % 65)

 

 
 
 

7. How can you compare two strings named “client1” and “client2” for alphabetical order?

 
 
 
 

8. What is the output of the add() function call:

def add(a, b):
   return a+5, b+5

result = add(3, 2)
print(result)
 
 
 
 

9. Select the all correct way to remove Annie’s hourly rate from the following dictionary?

staff = {
   "name": "Annie",
   "department": "Marketing",
   "hourly": 60
}

 

 
 
 

10. How do you increment a integer (e.g num = 10) variable by 1?

 
 
 
 

11. How can you print the word “banana” using  the following list:

fruit = ['apples','oranges','bananas','melons']
 
 
 
 

12. What is the output of the following display() function call:

def display(**kwargs):
   for i in kwargs:
      print(i)

display(emp="Kelly", salary=9000)
 
 
 

13. What is the output of the following union operation:

set1 = {10, 20, 30, 40}
set2 = {50, 20, "10", 60}

set3 = set1.union(set2)
print(set3)
 
 
 
 

14. Which function is used to accept input from the user?

 
 
 
 

15. What is the output of the following:

sampleTuple = "Apples", "Oranges", "Bananas"
item1, item2, item3 = sampleTuple
print(item1)
 
 
 

16. What is the output of the following math function:

import math
print(math.ceil(252.4))
print(math.floor(252.4))
 
 
 

17. What is the output:

print(2 ** 3 ** 2)
 
 

18. What is the output of the following:

testList = [5, 10, 15, 25]
print(testList[::-2])
 
 
 

19. Given the nested if-else below, what will be the value x when the code executed successfully

x = 0
a = 5
b = 5
if a > 0:
   if b < 0:
      x = x + 5
   elif a > 5:
      x = x + 4
   else:
      x = x + 3
else:
   x = x + 2

print(x)


 
 
 
 

20. What is the data type of the following:

tupleTest = (2, 'Bump', 2)
print(type(tupleTest[2:3]))
 
 
 

Question 1 of 20

Not sure about your answer? Try it out before making your choice.