INF1511-BeginnerExam pack
2022/2023
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
//Th...
#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
,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()
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through EFT, credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying this summary from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller Tutor23. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy this summary for R53,96. You're not tied to anything after your purchase.