INF1511-Beginner-Exam pack.
Question 1: What is a correct syntax to output "Hello World" in Python? print("Hello World") Your answer echo("Hello World"); p("Hello World") echo "Hello World" Question 2: How do you insert COMMENTS in Python code? #This is a comment Your answer //This is a comment /*This is a comment*/ Question 3: Which one is NOT a legal variable name? _myvar Your answer my_var my-var Correct answer Myvar Question 4: How do you create a variable with the numeric value 5? Both the other answers are correct Your answer x = int(5) x = 5 INF1511-Beginner-Exam pack. Question 5: What is the correct file extension for Python files? .py Your answer .pyt .pt .pyth Question 6: How do you create a variable with the floating number 2.8? x = float(2.8) Your answer Both the other answers are correct Correct answer x = 2.8 Question 7: What is the correct syntax to output the type of a variable or object in Python? print(type(x)) Your answer print(typeof(x)) print(typeOf(x)) print(typeof x) Question 8: What is the correct way to create a function in Python? def myFunction(): Your answer function myfunction(): create myFunction(): Question 9: In Python, 'Hello', is the same as "Hello" True Your answer False Question 10: What is a correct syntax to return the first character in a string? x = "Hello"[0] Your answer x = "Hello".sub(0, 1) x = sub("Hello", 0, 1) Question 11: Which method can be used to remove any whitespace from both the beginning and the end of a string? trim() Your answer strip() Correct answer len() ptrim() Question 12: Which method can be used to return a string in upper case letters? upper() Your answer toUpperCase() uppercase() upperCase(
Geschreven voor
- Instelling
- University of South Africa
- Vak
- INF1511 - Visual Programming I
Documentinformatie
- Geüpload op
- 25 november 2021
- Aantal pagina's
- 34
- Geschreven in
- 2021/2022
- Type
- Tentamen (uitwerkingen)
- Bevat
- Vragen en antwoorden
Onderwerpen
-
inf1511
-
inf1511 beginner exam pack