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. To generate a random secure Universally unique ID which method should I use

 
 
 
 

2. What will the following code output?

x = 5
y = "Paul"
print(x + y)

 

 
 
 

3. When working with a file what happens when using file mode x ?

Example code:

try: with open("fname", "x") as fout: 
   #Work with your open file 
except FileExistsError: 
   # Your error handling goes here
 
 
 

4. What is the output:

print(2 ** 3 ** 2)
 
 

5. What is the output:

print(10 - 4 * 2)
 
 

6. 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)


 
 
 
 

7. What is the output of the following:

testList = [1, 2, 3, 4, 5, 6, 7]
pow2 = [2 * x for x in testList]
print(pow2)
 
 

8. What is the output of the following function call:

def sampleFunc(name, age=20):
   print(name, age)

sampleFunc('Peter', 55)
 
 

9. What is the output of the following list operation:

testList = [10, 20, 30, 40, 50, 60, 70, 80]
print(testList[2:5])
print(testList[:4])
print(testList[3:])
 
 

10. What will be the output of the following code ?

sampleString = "Apples"
print(sampleString[1:4], sampleString[:5], sampleString[4:], sampleString[0:-1], sampleString[-2:-1])
 
 
 

11. What is the output of the following set operation:

sampleSet1 = {"Apples", "Oranges", "Bananas"}
sampleSet2 = {"Oranges", "Grapes", "Lemons"}

sampleSet1.difference_update(sampleSet2)
print(sampleSet1)
 
 

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

 

 
 
 

13. What is the type of the following variable:

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

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

 
 
 
 

15. How do you output content to the console with Python?

 
 
 
 

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

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

 

 
 
 

17. What will be the output?

for x in 'Marilyn': 
   if x != 'i': 
      print(x, end=" - ")
 
 
 

18. Which of the following operators has the highest precedence?

 
 
 
 

19. What is the output of this string operation?

testStr = 'Hello'
print(testStr*3)
 
 
 

20. Select the command that will convert a variable named “testStr” with value “The most amazing thing in the world” to “The Most Amazing Thing In The World”.

 
 
 
 

Question 1 of 20

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