Skip to content

Learning Python: Day 8

Using range() to make a list of numbers numbers = list(range(1, 6)) print(numbers) [1, 2, 3, 4, 5] even_numbers.py even_numbers – list(range(2, 11, 2)) print(even_numbers) [2, 4, 6, 8, 10] square_numbers.py squares = [] for value in range(1, 11): square… Read More »Learning Python: Day 8

Learning Python: Day 7

Chapter 4: Working with lists Looping through an entire list magicians.py magicians = [‘alice’, ‘david’, ‘carolina’] for magician in magicians: print(magician) alice david Carolina A closer look at looping Doing more work within a for loop magicians.py magicians = [‘alice’,… Read More »Learning Python: Day 7

Learning Python: Day 6

Chapter 3: (Continued) cars = [‘bmw’, ‘audi’, ‘toyota’, ‘subaru’] print(“Here is the original list:”) print(cars) print(“\nHere is the sorted list:”) print(sorted(cars)) print(“Here is the original list again:”) print(cars) Here is the original list: [‘bmw’, ‘audi’, ‘toyota’, ‘subaru’] Here is the… Read More »Learning Python: Day 6

Learning Python: Day 5

Chapter 3: (Continued) Adding elements to a list Appending elements to the end of a list motorcycles = [‘honda’, ‘yamaha’, ‘suzuki’] print(motorcycles) motorcycles.append(‘ducati’) print(motorcycles) [‘honda’, ‘yamaha’, ‘suzuki’] [‘honda’, ‘yamaha’, ‘suzuki’, ‘ducati’] motorcycles = [] motorcycles.append(‘honda’) motorcycles.append(‘yamaha’) motorcycles.append(‘suzuki’) print(motorcycles) [‘honda’, ‘yamaha’,… Read More »Learning Python: Day 5

Learning Python: Day 4

Chapter 3: Introducing Lists What is a list? bicycles.py bicycles = [‘trek’, ‘cannondale’, ‘redline’, ‘specialized’] print(bicycles) [‘trek’, ‘cannondale’, ‘redline’, ‘specialized’] Accessing elements in a list bicycles bicycles = [‘trek’, ‘cannondale’, ‘redline’, ‘specialized’] print(bicycles[0]) trek bicycles = [‘trek’, ‘cannondale’, ‘redline’, ‘specialized’]… Read More »Learning Python: Day 4

Learning Python: Day 3

Chapter 2: (Continued) Adding whitespace to strings with tabs or newlines >>> print(“Python”) Python >>> print(“\tPython”) Python >>> print(“Languages:\nPython\nC\nJavaScript”) Languages: Python C JavaScript >>> print(“Languages:\n\tPython\n\tC\n\tJavaScript”) Languages: Python C JavaScript Stripping whitespace >>> favorite_language = ‘Python ‘ >>> favorite_language ‘Python ‘… Read More »Learning Python: Day 3

Learning Python: Day 2

Chapter 2: What happens when running Hello_World.py print(“Hello Python world!”) –> input Hello Python world! –> output Variables message = “Hello Python world!” –> variable = value print(message) Hello Python world! Naming and using variables Avoiding name errors when using… Read More »Learning Python: Day 2

Learning Python: Day 1

Technically, this is like the 5th “Day 1” (read: I’ve given up… a lot), but I’m holding myself accountable by documenting my journey here. This past weekend I started reading Python Crash Course by Eric Matthes after multiple Reddit recommendations… Read More »Learning Python: Day 1