

Python-Function-Calls-and-Conditionals
Presentation
•
Computers
•
11th Grade
•
Practice Problem
•
Hard
Almotaz Al Muntaser
Used 1+ times
FREE Resource
10 Slides • 0 Questions
1
Python: Function Calls and
Conditionals
we will explore the fundamentals of function calls and
conditionals in Python.
by Al Motaz
LO: Students will be able to demonstrate a clear understanding of Python
function calls, including how to define and invoke functions, pass arguments,
and return values, enabling them to write more organized and modular code.
2
LO: Students will be able to demonstrate a clear understanding of Python
function calls, including how to define and invoke functions, pass arguments,
and return values, enabling them to write more organized and modular code.
All Will
•
Create a basic Python function
: All
students will be able to define a
function called that takes an integer
as an argument.
• Use a conditional assignment: All
students will use a conditional
assignment to determine whether
the number is even or odd.
• Print the result: All students will print
the result, indicating whether the
number is even or odd.
Most Will
• Provide user instructions: Most
students will add user instructions
to input a number and call the
function.
• Use descriptive variable names:
Most students will use descriptive
variable names within the function
and clear, user-friendly prompts
for input.
Some Will
• Include additional functionality:
Some students may choose to
extend the function to handle
other number properties, such as
checking for prime numbers or
performing arithmetic operations.
3
To use a function in Python, we simply write its name followed
by parentheses (print()). We can pass parameters(def ex(x) ) if
the function has arguments(x = ex(5)).
LO: Students will be able to demonstrate a clear understanding of Python
function calls, including how to define and invoke functions, pass arguments,
and return values, enabling them to write more organized and modular code.
In groups of 3:
• Create a function called calculate_rectangle_area
• This function takes two arguments called length
and width and calculates the area of a rectangle.
• Call this function with specific values for length
and width.
• Print the result
4
Function Basics
In programming, functions are reusable blocks
of code that perform specific tasks. They help
organize code and make it more modular
(smaller - cleaner).
LO: Students will be able to demonstrate a clear understanding of Python
function calls, including how to define and invoke functions, pass arguments, and
return values, enabling them to write more organized and modular code.
print()
• this function returns the number
of items in an object. When the
object is a string, the len() function
returns the number of characters
in the string.
Min()
• The min() method returns
the minimum element in the
case of integers or floating
type values.
Len()
• this function returns the number
of items in an object. When the
object is a string, the len()
function returns the number of
characters in the string.
5
Function Definition
To define a function in Python, we use the
def keyword followed by the function name,
parentheses, and a colon. We can also add
parameters inside the parentheses.
LO: Students will be able to demonstrate a clear understanding of Python
function calls, including how to define and invoke functions, pass arguments,
and return values, enabling them to write more organized and modular code.
Parameters or Arguments?
A parameter is the
variable listed
inside the
parentheses in the
function definition.
def num(a):
An argument is the
value that is sent to
the function when
it is called.
x = num(5)
6
Return Statement
The return statement is used to specify the value that a function should give back when it is
called. It ends the execution of the function.
LO: Students will be able to demonstrate a clear understanding of Python
function calls, including how to define and invoke functions, pass arguments,
and return values, enabling them to write more organized and modular code.
Print vs. return in Python
Printing and returning are completely
different concepts.
print is a function you call. Calling print will
immediately make your program write out
text for you to see. Use print when you want
to show a value to a human.
Using return changes the flow of the program.
Using print does not.
You can only use return
inside the function body.
Function definitions II
Important details
You can only use return inside a function body.
Note that printing and returning are completely different concepts. If the difference isn't completely clear to you, read this.
Important details
You can only use return inside a function body.
Note that printing and returning are completely different concepts.
7
Conditionals
In programming, conditionals help control the flow of
execution based on certain conditions. They allow us to
make decisions within our code.
LO: Students will be able to demonstrate a clear understanding of Python
function calls, including how to define and invoke functions, pass arguments,
and return values, enabling them to write more organized and modular code.
8
If Statement
The if statement is a fundamental conditional statement in Python. It executes a block of code
only if a certain condition is met.
LO: Students will be able to demonstrate a clear understanding of Python
function calls, including how to define and invoke functions, pass arguments,
and return values, enabling them to write more organized and modular code.
9
Exit Ticket
LO: Students will be able to demonstrate a clear understanding of Python
function calls, including how to define and invoke functions, pass arguments,
and return values, enabling them to write more organized and modular code.
https://quizizz.com/join/gam
e/U2FsdGVkX18T%252FpFYR
crZOe86vl0heWFAwZVszLJ64
m2onTvQj7FqB7IBcifCEAwA?
gameType=solo&page=nps&
page=summary
10
Python: Function Calls and
Conditionals
we will explore the fundamentals of function calls and
conditionals in Python.
by Al Motaz
LO: Students will be able to demonstrate a clear understanding of Python
function calls, including how to define and invoke functions, pass arguments,
and return values, enabling them to write more organized and modular code.
Show answer
Auto Play
Slide 1 / 10
SLIDE
Similar Resources on Wayground
6 questions
Gen Math Lesson Function
Presentation
•
11th Grade
8 questions
Unit 1 Introduction to Anatomy
Presentation
•
11th Grade
10 questions
Алфавит Python - 6 класс
Presentation
•
KG
10 questions
บทเรียนวิชาคอมพิวเตอร์พื้นฐาน
Presentation
•
KG
10 questions
Python _ review
Presentation
•
9th - 10th Grade
5 questions
Windows Server UEPDC
Presentation
•
11th Grade
7 questions
kidney structure and function
Presentation
•
11th Grade
7 questions
Year 11 - Oct. 29th, Conclusion Paragraph
Presentation
•
11th Grade
Popular Resources on Wayground
6 questions
PRIDE Always and Everywhere
Presentation
•
12th Grade
20 questions
Lab Safety Quiz
Quiz
•
6th Grade
26 questions
KOR Review Kahoot Questions
Quiz
•
8th Grade
21 questions
Continents and Oceans
Quiz
•
6th Grade
12 questions
Unit Zero lesson 2 cafeteria
Presentation
•
9th - 12th Grade
20 questions
Parts of Speech
Quiz
•
5th Grade
10 questions
Riddles Riddles fun Riddles
Quiz
•
6th - 12th Grade
16 questions
Subject & Predicate
Quiz
•
5th Grade