Tuesday, July 24, 2018

Python Data Structures Prev - Chapter 6 Quiz

What does the following Python Program print out?
1
2
3
4
str1 = "Hello"
str2 = 'there'
bob = str1 + str2
print(bob)
Question 2
1
point

2. Question 2

What does the following Python program print out?
1
2
3
x = '40'
y = int(x) + 2
print(y)
Question 3
1
point

3. Question 3

How would you use the index operator [] to print out the letter q from the following string?
1
x = 'From marquard@uct.ac.za'
Question 4
1
point

4. Question 4

How would you use string slicing [:] to print out 'uct' from the following string?
1
x = 'From marquard@uct.ac.za'
Question 5
1
point

5. Question 5

What is the iteration variable in the following Python code?
1
2
for letter in 'banana' :
print(letter)
Question 6
1
point

6. Question 6

What does the following Python code print out?
1
print(len('banana')*7)
Question 7
1
point

7. Question 7

How would you print out the following variable in all upper case in Python?
1
greet = 'Hello Bob'
Question 8
1
point

8. Question 8

Which of the following is not a valid string method in Python?
Question 9
1
point

9. Question 9

What will the following Python code print out?
1
2
3
data = 'From stephen.marquard@uct.ac.za Sat Jan 5 09:14:16 2008'
pos = data.find('.')
print(data[pos:pos+3])
Question 10
1
point

10. Question 10

Which of the following string methods removes whitespace from both the beginning and end of a string?

No comments:

Post a Comment