Coursera Answers

Python Data Structures Week 1 Quiz Answers

Python Data Structures Week 1 Quiz Answers


Python Data Structures Week 1 Quiz Answers


Python Data Structures

Offered By

  • University of Michigan

About this Course

This course will introduce the core data structures of the Python programming language. We will move past the basics of procedural programming and explore how we can use the Python built-in data structures such as lists, dictionaries, and tuples to perform increasingly complex data analysis. This course will cover Chapters 6-10 of the textbook “Python for Everybody”.  This course covers Python 3.


WHAT YOU WILL LEARN

  • Explain the principles of data structures & how they are used
  • Create programs that are able to read and write data from files
  • Store data as key/value pairs using Python dictionaries
  • Accomplish multi-step tasks like sorting or looping using tuples


SKILLS YOU WILL GAIN

  • Python Syntax And Semantics
  • Data Structure
  • Tuple
  • Python Programming


Go to this Course

https://www.coursera.org/learn/python-data



Week 1 Quiz Answer

Chapter Six: Strings

Question 1)

What does the following Python Program print out?


1234str1 = “Hello”

str2 = ‘there’

bob = str1 + str2print(bob)


  • Hello
  • Hellothere
  • Hello there
  • there
  • Hello



Question 2)

What does the following Python program print out?


x = ’40’

y = int(x) + 2

print(y)


  • x2
  • 402
  • 42
  • int402



Question 3)

How would you use the index operator [] to print out the letter q from the following string?

x = ‘From marquard@uct.ac.za’


  • print(x[9])
  • print(x[8])
  • print(x[7])
  • print x[-1]
  • print(x[q])


Question 4)

How would you use string slicing [:] to print out ‘uct’ from the following string?

x = ‘From marquard@uct.ac.za’

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


Question 5)

What is the iteration variable in the following Python code?

for letter in ‘banana’ :    

print(letter)

  • print
  • in
  • ‘banana’
  • for
  • letter


Question 6)

What does the following Python code print out?

print(len(‘banana’)*7)


  • 42
  • -1
  • banana7
  • banana banana banana banana banana banana banana

Question 7)

How would you print out the following variable in all upper case in Python?

greet = ‘Hello Bob’


  • puts(greet.ucase);
  • print(uc($greet));
  • print(greet.upper())
  • print(greet.toUpperCase());



Question 8)

Which of the following is not a valid string method in Python?


  • join()
  • shout()
  • split()
  • startswith()



Question 9)

What will the following Python code print out?

data = ‘From stephen.marquard@uct.ac.za Sat Jan  5 09:14:16 2008’

pos = data.find(‘.’)

print(data[pos:pos+3])


  • uct
  • 09:14
  • .ma
  • mar


Question 10)

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


  • wsrem()
  • strtrunc()
  • strip()
  • split()