Codehs Unit 7 Python
This section of CodeHS Unit 7 focuses on working with tuples and string formatting in Python. In 7.1.7, students learn how to modify a tuple by creating a new one using slicing and concatenation, reinforcing the concept that tuples are immutable.
7.1.7 Fix This Tuple
my_tuple = (0, 1, 2, "hi", 4, 5)
# Your code here...
my_tuple = my_tuple[:3] + (3,) + my_tuple[4:]
print(my_tuple)
Key Terms
7.1.7 Fix This Tuple
my_tuple = (0, 1, 2, "hi", 4, 5)
# Your code here...
my_tuple = my_tuple[:3] + (3,) + my_tuple[4:]
print(my_tuple)
7.1.8: Citation
def citation(names):
author_name = ((names))
name = str(names[2]) + ", " + str(names[0]) + " " + str(names[1])
return name
print(ci...
7.1.9: Diving Contest
# fill in this function to return the total of the three judges' scores!
judges_scores=(10,10,10)
def calculate_score(judges_scores):
...
7.1.10: Coordinate Pairs
import math
# fill in this function to return the distance between the two points!
first_point = (1, 1)
second_point = (4, 5)
<...
7.2.6: Spell It Out
# fill in this function to return a list containing each character in the name
name = "Jessica"
def spell_name(name):
spell_out = list...
7.2.8: Listed Greeting
# fill in this function to greet the user!
user_info = "Booba"
def greeting(user_info):
greeting = user_info.split()
return "He...
Related Flashcard Decks
Study Tips
- Press F to enter focus mode for distraction-free studying
- Review cards regularly to improve retention
- Try to recall the answer before flipping the card
- Share this deck with friends to study together
Term | Definition |
---|---|
7.1.7 Fix This Tuple | my_tuple = (0, 1, 2, "hi", 4, 5) |
7.1.8: Citation | def citation(names): |
7.1.9: Diving Contest | # fill in this function to return the total of the three judges' scores! |
7.1.10: Coordinate Pairs | import math |
7.2.6: Spell It Out | # fill in this function to return a list containing each character in the name |
7.2.8: Listed Greeting | # fill in this function to greet the user! |
7.2.9 Top Movies | # Enter your code here |
7.3.6: Max In List | # your function should return the maximum value in |
7.3.7: Owls | # this function should return the number of words that contain "owl"! |
7.3.8: Exclamat!on Po!nts | def exclamation(text): |
7.3.9 Word Ladder | user_string = input("Enter a string: ") |
7.4.4 How Many Names? | nn = int(input("How many names do you have?:")) |
7.4.5 Five Numbers | list=[] |
7.4.7 Librarian | list=[] |
7.4.12 Empty List (Append and Remove) | my_list = [] |
7.4.13: Take a Thing Out, Sort It, and Reverse It | my_list=["eggplant", "apple", "zucchini", "rambutan", "grapefruit"] |
7.4.14 Librarian, Part 2 | list=[] |
7.4.15 Owls, Part 2 | text = input("Enter some text: ") |
7.5.4 Simulating a Coin Flip | import numpy as np |