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 4, Chapter 2, Python for Data Structure

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

      1.How are “collection” variables different from normal variables?

        Answer-

      Collection variables can store multiple values in a single variable

      2.What are the Python keywords used to construct a loop to iterate through a list?

        Answer-

      for/in

      3.For the following list, how would you print out ‘Sally’?
      friends = [ ‘Joseph’, ‘Glenn’, ‘Sally’]

        Answer-

      print(friends[2])

      4. fruit = ‘Banana’
      fruit[0] = ‘b’;
      print fruit

        Answer-

      Nothing would print the program fails with a traceback.

      5.Which of the following Python statements would print out the length of a list stored in the variable data?

        Answer-

      print(len(data))

      6.What type of data is produced when you call the range() function?
      x = range(5)

        Answer-

      A list of integers

      7.What does the following Python code print out?
      a = [1, 2, 3];
      b = [4, 5, 6];
      c = a + b;
      print(len(c))

        Answer-

      6

      8.Which of the following slicing operations will produce the list [12, 3]?
      t = [9, 41, 12, 3, 74, 15]

        Answer-

      t[2:4]

      9.What list method adds a new item to the end of an existing list?

        Answer-

      append()

      10.What will the following Python code print out?
      friends = [ ‘Joseph’, ‘Glenn’, ‘Sally’ ];
      friends.sort();
      print(friends[0])

        Answer-

      Glenn

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