Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Other

Python Programming Notes for Beginners – Full Course Summary

Rating
-
Sold
-
Pages
27
Uploaded on
04-11-2025
Written in
2025/2026

This document contains complete and well-organized notes covering all key topics from the syllabus. It includes definitions, explanations, solved examples, and important questions for quick revision before exams. The notes are easy to understand and ideal for students preparing for assignments, tests, and final exams. Suitable for both beginners and advanced learners.

Show more Read less
Institution
Course

Content preview

Chapter-4
Python Functions



Python Functions is a block of statements that return the specific
task. The idea is to put some commonly or repeatedly done tasks
together and make a function so that instead of writing the same
code again and again for different inputs, we can do the function
calls to reuse code contained in it over and over again.
Some Benefits of Using Functions
 Increase Code Readability
 Increase Code Reusability
Python Function Declaration
The syntax to declare a function is:

Syntax of Python Function Declaration


Types of Functions in Python
There are mainly two types of functions in Python.
 Built-in library function: These are Standard functions in
Python that are available to use.
 User-defined function: We can create our own functions
based on our requirements.
Creating a Function in Python
We can define a function in Python, using the def keyword. We can
add any type of functionalities and properties to it as we require.
 Python3


# A simple Python function

def fun():
print("Welcome to GFG")

Calling a Python Function
After creating a function in Python we can call it by using the name
of the function followed by parenthesis containing parameters of
that particular function.

,  Python3


# A simple Python function
def fun():
print("Welcome to GFG")


# Driver code to call a function
fun()

Output:
Welcome to GFG
Python Function with Parameters
If you have experience in C/C++ or Java then you must be thinking
about the return type of the function and data type of arguments.
That is possible in Python as well (specifically for Python 3.5 and
above).
Defining and calling a function with parameters
def function_name(parameter: data_type) -> return_type:
"""Docstring"""
# body of the function
return expression
The following example uses arguments and parameters that you will
learn later in this article so you can come back to it again if not
understood.
 Python3


def add(num1: int, num2: int) -> int:
"""Add two numbers"""
num3 = num1 + num2

return num3

# Driver code
num1, num2 = 5, 15
ans = add(num1, num2)
print(f"The addition of {num1} and {num2} results {ans}.")

Output:
The addition of 5 and 15 results 20.
Note: The following examples are defined using syntax 1, try to
convert them in syntax 2 for practice.

,  Python3


# some more functions
def is_prime(n):
if n in [2, 3]:
return True
if (n == 1) or (n % 2 == 0):
return False
r = 3
while r * r <= n:
if n % r == 0:
return False
r += 2
return True
print(is_prime(78), is_prime(79))

Output:
False True
Python Function Arguments
Arguments are the values passed inside the parenthesis of the
function. A function can have any number of arguments separated
by a comma.
In this example, we will create a simple function in Python to check
whether the number passed as an argument to the function is even
or odd.
 Python3


# A simple Python function to check
# whether x is even or odd
def evenOdd(x):
if (x % 2 == 0):
print("even")
else:
print("odd")


# Driver code to call the function
evenOdd(2)
evenOdd(3)

Output:
even
odd

Written for

Course

Document information

Uploaded on
November 4, 2025
Number of pages
27
Written in
2025/2026
Type
OTHER
Person
Unknown

Subjects

$15.49
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
archanasarangi

Also available in package deal

Get to know the seller

Seller avatar
archanasarangi synergy institute of engineering and technology dhenkanal
Follow You need to be logged in order to follow users or courses
Sold
1
Member since
6 months
Number of followers
0
Documents
4
Last sold
6 months ago

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions