The Python practice quiz is designed to check your understanding in one of the most common programming languages. The practice quiz covers the basics of Python as well as a few advanced topics. However, the quiz is primarily intended for people who are new to the language and have learned by reading the tutorials on the website.
1. In Python, what is one function to output content to the console?
2. Which of the following statements is NOT true about Python?
3. What symbol can you use to comment out one line of code?
4. What can you put before and after a section to make all of the lines a comment?
5. How do you create a variable "a" that is equal to 2?
6. How would you cast the string variable "a" that is equal to "2" into the integer 2?
7. How would you cast the int variable "a" that is equal to 2 into the string "2"?
8. Which of the following is not a valid assignment operator?
10. What keyword would you use to add an alternative condition to an if statement?
11. Which of the following is a valid way to start a function in Python?
12. Which of the following is a valid for loop in Python?
13. Which of the following is a valid way to start a while loop in Python?
14. If you have a variable "example", how do you check to see what type of variable you are working with?
15. How can you replace all of the letter a in a string variable "example" with the letter b?
16. Which of the following is a valid list in Python?
17. Which of the following is a valid tuple in Python?
18. Which of the following is a valid dictionary in Python?
19. How would you print the second item in the list variable "example"?
20. What would the statement "print('%.2f' % 123.444)" print out?
21. What is the keyword used after the try statement to handle exceptions?
22. What is the proper way to open a file that you intend to read from?
23. What is the proper way to open a file that you plan to write to?
24. If you had a statement like, "f = open("test.txt","w")", what would happen to the file as soon as that statement is executed?
Python will save the file's contents and append whatever the code following says to write.
25. What is the difference between a class and an object in Python?
Classes are made from iterations while objects are not.
Objects are not able to be called.