Study

cosce7391 george and alex week 9

  •   0%
  •  0     0     0

  • 1. What is a data structure used for in programming?
    To execute loops in a program
    To store multiple values in a single variable
    To store a single value in a variable
    To define functions in a program
  • What will the code print(sports[3]) output if the list is sports = ["basketball", "soccer", "tennis", "volleyball"]?
    basketball
    tennis
    soccer
    volleyball
  • Which data structures in Python are used for storing multiple values in a single variable?
    Tuple and Dictionary
    List and Tuple
    Set and Dictionary
    List and String
  • What function is used to insert a value at the end of a list?
    append_value()
    insert()
    add()
    append()
  • How do you access each element in a list using a for loop?
    for x from list:
    for x in list: print(x)
    for x in range(len(list)): print(x)
    for each in list: print(each)
  • What does the remove() function do in Python lists?
    It removes a specified value from the list
    It removes the last value from the list
    It removes all values from the list
    It removes the first
  • How can you access the first value in a list in Python?
    list[3]
    list[1]
    list[2]
    list[0]
  • How do you change the value of an element at a specific index in a list?
    list.change(<INDEX>, <VALUE>)
    list[<INDEX>] = <VALUE>
    list.set(<INDEX>, <VALUE>)
    list.update(<INDEX>, <VALUE)
  • Which function is used to retrieve the total count of values in a list?
    total()
    size()
    count()
    len()
  • How do you create a list in Python?
    list = []
    list = ()
    list = {}
    list = <>