Python Pro summer classes
July 2025
1 What is an Algorithm?
An algorithm is like a recipe for your favorite cookies! It’s a step-by-step set of instructions
to solve a problem or complete a task. For example, to make a sandwich, you might follow
these steps:
1. Grab two slices of bread.
2. Spread peanut butter on one slice.
3. Spread jelly on the other slice.
4. Put the slices together.
In programming, algorithms tell the computer what to do!
2 What is a Programming Language?
A programming language is how we "talk" to computers. It’s a special language with
rules that computers understand. Just like you speak English or Spanish to friends,
programmers use languages like Python or Java to give instructions to computers. We’re
going to use Python because it’s super easy and fun!
3 What is a Program?
A program is a bunch of instructions written in a programming language that tells the
computer to do something cool, like play a game or show a picture. Think of it as a list
of commands that the computer follows, like a script for a play!
4 What are Built-in Functions?
Built-in functions are like magic buttons in Python that do specific jobs for you. Theyre
already made for you to use, so you dont have to create them! You just call them by
their name, and they do something cool, like showing text on the screen or asking the
user for input. Here are a couple of examples you already know:
• print(): This function shows stuff on the screen, like text or numbers.
• input(): This function asks the user to type something and grabs what they type.
Heres how they work:
1 print ( " Hey , this is fun ! " ) # Shows : Hey , this is fun !
2 name = input ( " What ’s your name ? " ) # Waits for you to type
3 print ( " Hi , " , name , " ! " ) # Shows : Hi , [ whatever you typed ]!
Built-in functions are like tools in a toolboxready to use whenever you need them!
1
5 The Print Function
The print function in Python is like shouting something to the screen. It shows text or
numbers to the user. Here are some examples:
1 print ( " Hello , World ! " ) # Outputs : Hello , World !
2 print (42) # Outputs : 42
3 print ( " I am " , 15 , " years old ! " ) # Outputs : I am 15 years old !
Try it out! You can print anything you want.
6 What are Variables?
Variables are like labeled boxes where you store stuff, like numbers or words. They help
you keep track of information in your program. Here’s why they’re awesome:
• They make your code easier to read.
• You can change what’s in the box anytime!
Here’s how to use variables in Python:
1 age = 15
2 name = " Sam "
3 print ( name , " is " , age , " years old ! " ) # Outputs : Sam is 15 years old !
4 age = 16 # Update the age
5 print ( name , " is now " , age ) # Outputs : Sam is now 16
You can store numbers, text, or even lists in variables!
7 The Input Function
The input function lets you ask the user to type something. It’s like saying, "Hey, tell
me something!" Whatever the user types comes back as a string (text), even if they type
a number. If you need a number, you can convert it using int().
Here’s an example:
1 name = input ( " What ’s your name ? " )
2 print ( " Nice to meet you , " , name , " ! " )
3
4 age = input ( " How old are you ? " )
5 age = int ( age ) # Convert string to number
6 print ( " In 5 years , you ’ ll be " , age + 5)
Run this, and it will ask for your name and age, then tell you how old you’ll be in 5 years!
8 Fun with Strings
Strings are text, like "Hello" or "Pizza". You can do cool things with them! Here are some
tricks:
2
8.1 Finding the Length of a String
The len() function tells you how many characters are in a string:
1 word = " Python "
2 print ( len ( word ) ) # Outputs : 6
8.2 Slicing Strings
Slicing lets you grab parts of a string. You use square brackets [start:end] to pick
which characters you want:
1 text = " I love coding ! "
2 print ( text [0:6]) # Outputs : I love
3 print ( text [7:12]) # Outputs : coding
4 print ( text [2:]) # Outputs : love coding !
The number before the colon is where to start, and the number after is where to stop
(but it doesn’t include that spot).
8.3 Finding a Word in a String
The find() method looks for a word in a string and tells you where it starts:
1 sentence = " Coding is super fun ! "
2 print ( sentence . find ( " super " ) ) # Outputs : 10
If the word isn’t there, it returns -1.
9 Wrap-Up
Now you know the basics of programming! You can write algorithms, use functions, store
stuff in variables, get input from users, and play with strings. Try making your own
program, like a quiz or a story generator. Coding is all about having fun and creating
cool stuff!