Python Quiz 2 Welcome to your Python Quiz n°1 ! 1. How to convert the variable "stringInt" to integer ? integer(stringInt) cast(stringInt,"integer") int(stringInt) str(stringInt) 2. Let's consider that we have a variable a="one word". What is the function that retrieves the type of the variable? type(a) a.type() a.type Type(a) 3. In Python, what is one function to output content to the console? output print console.log echo 4. What syntax allows to replace the sub-string "abc" by "dfe" in the string variable "myword" ? myword.replace(‘dfe’,’abc’) myword.match(‘abc’,’dfe’) myword.replace(‘abc’,’dfe’) myword.swap(‘abc’, ‘dfe’) 5. Which of the following is a valid list in Python? l = [1,2,3,4,5] l = (1,2,3,4,5) l = {1,2,3,4,5} l = 1,2,3,4,5 6. How to convert the variable intString to a string ? cast(intString as string) int(intString,"string") str(intString) string(intString) 7. Which one of the following is a valid Python if statement ? if a <=30: if a <=30 {} if a =<30 if (a <=30) 8. How do you create a variable “number” that is equal to 5? var number = 5 int number = 5 variable number = 5 number = 5 9. What syntax is correct for declaring a function? function test(): def test(): function test() def test(): 10. What symbol can you use to comment out one line of code? # /// /*** (comment) By ayed_amira I'm a data scientist. Passionate about new technologies and programming I created this website mainly for people who want to learn more about data science and programming :) View all of ayed_amira's posts.