programming-fundamentals
  • Introduction
  • Lesson 1
    • Writing Your First Program
    • Data Types
    • Built In Functions
    • If Statements
    • Using Git and Github
    • Primer
    • Questions
    • Tip Calculator
    • GPA Calculator (optional)
  • Lesson 2
    • Modules
    • Lists
    • Data Structures
    • More On Data Structures
    • Questions
    • Madame Zamad
    • Mad Libs
  • Lesson 3
    • While Loops
    • For Loops
    • Loops and Lists
    • Special Commands
    • Questions
    • TODO List
    • Fibonacci (optional)
  • Lesson 4
    • Functions
    • More Functions
    • Error Handling
    • File I/O
    • Questions
    • Sudoku
Powered by GitBook
On this page

Was this helpful?

  1. Lesson 2

Questions

  • True or False, modules are code that you import into your program for added

    functionality?

  • Give an example of using the math module.

  • How can you import all of module's functions into your program so you don't

    have to continually write name_of_module.function()?

  • What does immutable mean?

  • What is the difference between a list and a tuple?

  • What is the difference between a list and a dictionary?

  • How could you get the second-to-last item in a list?

  • Do all of the items in lists or dictionaries have to be the same data type?

  • Based on the following list, how could you get another list from index 2 to

    index 4?

[5, 2, 3, 6, 8, 2]
  • How could you check to see if 4 exists in the list above?

  • Using the code below, what is the value of right_answer?

right_answer = [4, 2]
wrong_answer = right_answer
wrong_answer[1] = 5
  • Using the code below, what is the value of spam?

green_eggs = 'yum'
spam = 'weird'
my_plate = green_eggs
green_eggs = spam
spam = my_plate
  • Suggest one way that you can avoid the problem of accidentally modifying a

    list you didn't mean to.

PreviousMore On Data StructuresNextMadame Zamad

Last updated 5 years ago

Was this helpful?