Search the courses, subjects, tracks, games and features, or jump straight to a page.
Learn it your way
A short class with Sarah and her students. The other ways are under More.
Sign up free to listen. Transcripts are free to read.
Today, we are going to write our first program in Python! Let's start with something simple: printing your name. Can anyone tell me how we can do that?
I think we can use the print() function!
Excellent! The print() function is used to display information on the screen. Now, who can give me an example of how to print their name?
I would write: print('My name is John.').
Great job! Remember, the text inside the quotes is called a string. Let's all try this out together! I'll give you a moment to run this code.
I did it! Now it shows 'My name is John' on the screen!
Awesome! Now, can anyone tell me why the print() function is useful?
It helps us see what our code is doing!
Exactly! To summarize: today we learned how to use the print() function to display our name. Nice work, everyone!
Now that we've printed our names, let’s move on to printing a number. What command would we use?
We will still use the print() function!
Correct! But instead of a string, we can print a number directly. For example, we can write: print(100). Who can tell me what this does?
It should display the number 100 on the screen!
Yes! Let's try it out together. I want everyone to write print(100) and run it.
Mine worked! It printed 100!
Excellent! Printing numbers opens the door to mathematical operations. Can anyone think of a reason why printing numbers might be useful in programming?
We can use it for calculations, or to show results of other operations!
Exactly! You are all doing wonderfully. Today we've learned how to print not just strings, but also numeric values. Let’s keep going!
Finally, let’s combine what we’ve learned so far and try printing a_math_result. We can do this with another print() command. Who can guess what we might print this time?
Maybe we can do some math, like print(5 + 7)?
Absolutely right! The expression 5 + 7 is evaluated, and print will display the result. Let's try typing that out.
I see it! It printed 12!
Wonderful! This shows how Python can handle arithmetic. Why do you think it is important to understand how to use these simple math operations in our code?
Because we might need to calculate things in our programs!
Exactly! Whether for games, data analysis, or more, math is everywhere in programming. Let’s recap what we’ve learned today. We printed our names, we printed a number, and finally, we printed the result of a simple calculation. Great job, everyone!
When you want your message to show, type print and let it flow.
Imagine a character named Print who loves to tell everyone about numbers and messages, spreading joy with every line they print!
To remember how to print: 'P for Print, I for Into the console, N for Numbers, T for Text!'
P-Print, I-Input, N-Number, T-Text - a reminder that print can handle it all!
Term
How do you print text in Python?
Click to flip
Term
What does `print(3 + 4)` output?
Click to flip
A built-in Python function used to output text or values to the console.
A sequence of characters enclosed in quotation marks.
A value representing a number, which can be integer or floating-point.
A mathematical operation like addition, subtraction, multiplication, or division.
This section encourages learners to practice writing and executing simple Python programs.
In this section, students will write and run their first Python programs, including printing their name, a number, and a simple math result. This hands-on approach reinforces learning through practical application.
This section focuses on practical exercises for students to gain hands-on experience with Python programming. Learners are tasked to write and execute three simple Python programs using the print() function. The exercises include:
Printing their name using:
print("My name is Alex.")This will introduce them to basic string output in Python.
Printing a number:
print(100)This will give them a chance to see how numeric values are handled.
Printing a mathematical result:
print(5 + 7)This demonstrates how Python can perform simple arithmetic operations.
Through these exercises, students begin to familiarize themselves with code structure, syntax, and the immediate feedback that Python provides. Hands-on practice is essential for grasping fundamental concepts, and successfully running these scripts marks an important step in their Python learning journey.