0% found this document useful (0 votes)
255 views7 pages

Introduction To Print in Python

Print

Uploaded by

Andrew Yardy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
255 views7 pages

Introduction To Print in Python

Print

Uploaded by

Andrew Yardy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Introduction to print() in Python

The print() function is used to display information to the screen. It's one of the first and most commonly used
functions in Python, making it essential for debugging and interacting with users.
Your First Python Output
The Classic Example
Every Python journey begins with the same simple command that
connects you to your program's output.

print("Hello, world!")

Output:

Hello, world!

This single line demonstrates the fundamental purpose of print() -


transforming your code's thoughts into visible results on the
screen.
The print() function - a buit-in Function
print() is a built-in-function. Built-in functions are a piece of prewritten code that performs an operation. They are
always available in Python without requiring you to do any extra coding to use. They provide short-cuts to do things
easily keeping your code clean and manageable. They are fundamental to Python programming and perform
common tasks.
Understanding Functions and Arguments
What is a Function? Arguments are Input print() is Built-in
A function is a block of reusable Functions can accept arguments Python provides print() as a
code that performs a specific - these are the input values that built-in function, meaning it's
action. Think of it as a tool that tell the function what to work always available without
takes input and produces output. with. importing additional modules.

print("Welcome", "to", "Python!")

The print() function takes the arguments "Welcome", "to", and "Python!" and displays them separated by spaces,
creating a cohesive message from individual parts.
Common Print Syntax and
Features
01 02

Single Argument Multiple Arguments

print("Hello") print("Hello", "World")

Separate multiple values with Separate multiple values with


commas to display them commas to display them
together. together.
Hello Hello World
Debugging with print()
Print is Your Debugging Friend
One of print()'s most valuable roles is helping you understand what's happening inside your code. By strategically
placing print statements, you can trace your program's execution and identify issues.
Debugging Example: Tracing Logic
Step-by-Step Debugging
Debugging Benefits
#Let’s use print() to test a program that adds the scores from two • Track variable changes
assignments. • Verify loop iterations
• Understand program flow
assignment_1=30
assignment_2=10 • Identify unexpected behaviour
score= assignment_1 + assignment_2
print(score)

Expected Output:

40

You might also like