Lesson 7 · Python for Data Science
Python and Jupyter Notebooks for Beginners: A Step-by-Step Guide
In this video, we will explore Python basics using Jupyter. Jupyter notebooks help you write and run code step by step. Python is a popular language for…
- CoursePython for Data Science
- Lesson7 of 38
- Video20 min
- FormatJupyter notebook · 26 code cells
What you'll learn
Data
No separate download needed — the notebook creates or downloads everything it uses.
📓 Full notebook
Download .ipynb
Welcome to Your First Python Jupyter Notebook Lesson!#
In this video, we will explore Python basics using Jupyter.
Jupyter notebooks help you write and run code step by step.
Python is a popular language for beginners because it is easy to read and use.
Let us get started and see what Python can do!
What is a Jupyter notebook?#
Jupyter notebooks let you mix code, explanations, and results.
You can run code in small pieces, called cells.
This makes it easy to learn, try things, and fix mistakes.
# Let us print a friendly message
print('Hello, world!')
# Variables store data so you can use it later
name = 'Alice'
print(name)
# Use input() to ask the user a question
user_food = input('What is your favorite food? ')
print('Yum! I like', user_food, 'too.')
# Math is easy in Python
a = 5
b = 3
sum_ab = a + b
print('5 plus 3 is', sum_ab)
Practice: Print your name and age#
Try using print() to show your name and age in a message.
# Python can do more than just print text.
# It can store different types of data.
age = 21
height = 1.75
is_student = True
print('Age:', age)
print('Height (meters):', height)
print('Student status:', is_student)
# You can put several things together in a list.
colors = ['red', 'green', 'blue']
print('Favorite colors:', colors)
# Access items in a list using square brackets.
print('First color:', colors[0])
print('Second color:', colors[1])
# Use input to build your own list
animal_1 = input('Name an animal: ')
animal_2 = input('Name another animal: ')
animals = [animal_1, animal_2]
print('Your animals:', animals)
# Lists can be changed after you create them.
colors.append('yellow')
print('New colors list:', colors)
# Remove an item from a list
colors.remove('green')
print('Colors after removing green:', colors)
# Sometimes things go wrong. Let us handle errors.
try:
colors.remove('purple')
except ValueError:
print('Could not find purple!')
Useful List Methods#
- .append(): Add an item
- .remove(): Delete an item by value
- .pop(): Take out an item by place
- .sort(): Put items in order
Try using these on your own list!
# You can repeat actions with loops.
for color in colors:
print('Color:', color)
# List comprehensions are a quick way to create new lists.
squared = [x * x for x in range(5)]
print('Squares:', squared)
# Sort a list in alphabetical order.
colors.sort()
print('Sorted colors:', colors)
# Combine two lists together.
combined = colors + animals
print('All items:', combined)
# Real-world data: make a shopping list
shopping = []
for i in range(3):
item = input(f'Enter item {i+1}: ')
shopping.append(item)
print('Your shopping list:', shopping)
# Mini-Project: Find the longest word in your shopping list
longest = ''
for word in shopping:
if len(word) > len(longest):
longest = word
print('The longest word on your list is:', longest)
# Best practice: check before removing items
if 'milk' in shopping:
shopping.remove('milk')
else:
print('Milk was not found in the shopping list.')
print('Shopping list now:', shopping)
# Common mistake: spelling errors
# watch for spelling differences in item names
if 'bread' in shopping:
print('Bread found!')
else:
print('Bread is missing. Check your spelling!')
# Tips: Make a backup of your list using copy()
backup = shopping.copy()
shopping.clear()
print('Backup:', backup)
print('Cleared shopping:', shopping)
# Challenge: practice with your own list
my_list = []
for i in range(2):
word = input('Add anything: ')
my_list.append(word)
print('Your list:', my_list)
Recap: You did it!#
You learned how to:
- Print messages
- Store data in variables and lists
- Use input() and loops
- Modify, sort, and combine lists
- Practice safe coding
Keep experimenting and practicing.
Every new notebook is a chance to learn and grow!
Thank you for learning Python in Jupyter Notebooks!#
If you found this lesson helpful, please like the video, leave a comment, and subscribe for more beginner Python tutorials!
Share your notebook with a friend and help them start learning too.
Happy coding!
Found this useful?
All lessons, notebooks and datasets here are free. If they helped you, a coffee keeps new lessons coming.



