Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Chapter 7 Quiz - Coursera

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

1/4/2016

Chapter6Quiz|Coursera

Chapter 6 Quiz
10questions

1.
What does the following Python Program print out?
str1="Hello"
str2='there'
bob=str1+str2
printbob

Hello there
Hellothere
Hello
Hello
there

2.
What does the following Python program print out?
x='40'
y=int(x)+2
printy

42
x2
int402
https://www.coursera.org/learn/pythondata/exam/y85mg/chapter6quiz

1/5

1/4/2016

Chapter6Quiz|Coursera

402

3.
How would you use the index operator [] to print out the letter q from the
following string?
x='Frommarquard@uct.ac.za'

print x[9]
print x[-1]
print x[8]
print x[7]
print x[q]

4.
How would you use string slicing [:] to print out 'uct' from the following
string?
x='Frommarquard@uct.ac.za'

print x[15:3]
print x[14:3]
print x[14/17]
print x[14+17]
print x[15:18]
print x[14:17]

https://www.coursera.org/learn/pythondata/exam/y85mg/chapter6quiz

2/5

1/4/2016

Chapter6Quiz|Coursera

5.
What is the iteration variable in the following Python code?
forletterin'banana':
printletter

print
letter
in
for
'banana'

6.
What does the following Python code print out?
printlen('banana')*7

banana7
42
0
bananabananabananabananabananabananabanana

7.
How would you print out the following variable in all upper case in
Python?
greet='HelloBob'

https://www.coursera.org/learn/pythondata/exam/y85mg/chapter6quiz

3/5

1/4/2016

Chapter6Quiz|Coursera

console.log(greet.toUpperCase());

putsgreet.ucase;

printuc($greet);

printgreet.upper()

8.
Which of the following is not a valid string method in Python?
boldface()
upper()
lower()
lstrip()
startswith()

9.
What will the following Python code print out?
data='Fromstephen.marquard@uct.ac.zaSatJan509:14:162008
'
pos=data.find('.')
printdata[pos:pos+3]

uct

https://www.coursera.org/learn/pythondata/exam/y85mg/chapter6quiz

4/5

1/4/2016

Chapter6Quiz|Coursera

.ma
09:14
mar

10.
Which of the following string methods removes whitespace from both the
beginning and end of a string?
wsrem()
strtrunc()
strip()
split()

Submit Quiz

https://www.coursera.org/learn/pythondata/exam/y85mg/chapter6quiz

5/5

You might also like