Phone

+919997782184

Email

support@roboticswithpython.com

Geeks of Coding

Join us on Telegram

Home Forums Assignment courserra Python for Everybody – Specialization Python Data Structures Week 1 Chapter 6, Python Data Structure

Viewing 0 reply threads
  • Author
    Posts
    • #806
      Abhishek TyagiAbhishek Tyagi
      Keymaster

      1.What does the following Python Program print out?

        Answer-
      str1 = "Hello"
      str2 = 'there'
      bob = str1 + str2
      print(bob)
      ==>Hellothere

      2.What does the following Python program print out?

        Answer-
      x = '40'
      y = int(x) + 2
      print(y)
      ==>42

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

        Answer-
      x = 'From marquard@uct.ac.za'
      ==>print(x[8])

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

        Answer-
      x = 'From marquard@uct.ac.za'
      ==>print(x[14:17])

      5.What is the iteration variable in the following Python code?

        Answer-
      for letter in 'banana' :
          print(letter)
          >letter

      6.What does the following Python code print out?

        Answer-
      print(len('banana')*7)
         42

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

        Answer-
      greet = 'Hello Bob'
        print(greet.upper())

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

        Answer-

      Boldface

      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])
        Answer-

      .ma

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

        Answer-

      strip()

Viewing 0 reply threads
  • You must be logged in to reply to this topic.