This module covers the fundamental concepts of Python programming, including symbols, basic data types, order of operations, lists, and tuples. Students will learn how to write and execute Python code, understand variable assignment, and manipulate data structures.
Outcomes:
Links:
Basic types:
backticks)Basic operators/symbols:
Tuple:
1, 2x, y = 1, 2Lists:
[1, 2, 3]list[0]list[-1]range(0, 10)
list[start:end] (end is exclusive)What is the difference between “x” and ‘x’ in Python?
Is 7 is equal “7”?
Write code to store the value 10 in a variable named score.
Write code to see if the value 10 is in a variable named score.
What is the result of 8 % 3?
Write code to raise 2 to the power of 8.
Combine operators: What is the result of 3 * 2 ** 2 + 1?
Write a line of code that checks if a variable a is greater than or equal to 5.
What is the difference between 10/3 and 10 // 3?
What symbol keeps Python from executing a line of code?
Write the syntax to create a list of the numbers 10, 20, 30, 40, and 50.
Print the first item in the list.
Print the last item in the list.
What happens if you try to access my_list[5]?
Write the syntax to create a tuple with the values 100, 200, and 300.
Write the syntax to change the 2nd item in the tuple to 25.
Return the a slice of the list that contains the 2nd and 3rd items.