Photo AI
Last Updated Sep 26, 2025
Revision notes with simplified explanations to understand Python Programming : Advanced quickly and effectively.
432+ students studying
Nested conditionals involve placing one conditional statement inside another. This is useful when you need to check multiple conditions in a hierarchical manner.
For example, an e-commerce platform wants to determine the discount to offer to different customers based on age and membership
age = 45
is_member = True
if age < 18 or age >= 65:
discount = "Senior / Child Discount"
elif 18 <= age < 65:
if is_member:
discount = "Member Discount"
else:
discount = "No Discount"
print("Discount : " + discount)
Nested loops involve placing one loop inside another loop.
list1 = ['a', 'b', 'c']
list2 = [1, 2, 3]
for item1 in list1:
for item2 in list2:
print(f"({item1}, {item2})")
"""
(a, 1)
(a, 2)
(a, 3)
(b, 1)
(b, 2)
(b, 3)
(c, 1)
(c, 2)
(c, 3)
"""
Functions are a fundamental aspect of Python programming. They allow you to encapsulate code into reusable blocks, making your code more modular, readable, and easier to maintain.
We've been using functions this entire time such as print and range. Now we will write our own functions.
The basic syntax of a function is :
def function_name(parameters):
# Function body
# Code to execute
return result # Optional
Let's write a function that takes in a number, and return the square of that number.
def square(x):
return x * x
print(square(5)) # Output: 25
print(square(3)) # Output: 9
print(square(2)) # Output: 4
Recursion is a programming technique where a function calls itself in order to solve smaller instances of the same problem.
It is often used to solve problems that can be broken down into smaller, repetitive tasks. Recursion is a powerful tool, but it must be used with care to avoid infinite loops and stack overflow errors.
A recursive function typically has two main components:
For example, in mathematics, the factorial of a non-negative integer is the product of all positive integers less than or equal to .
For instance, . Let's analyse the factorial of 5 closer.
We can observe how recursion is used to break down the factorial function into smaller factorials.
def factorial(n):
# Base case: if n is 0, return 1
if n == 0:
return 1
else:
# Recursive case: return n * factorial(n - 1)
return n * factorial(n - 1)
Here is a visual representation of the recursive calls :
factorial(4)
-> 4 * factorial(3)
-> 3 * factorial(2)
-> 2 * factorial(1)
-> 1 * factorial(0)
-> 1
Enhance your understanding with flashcards, quizzes, and exams—designed to help you grasp key concepts, reinforce learning, and master any topic with confidence!
30 flashcards
Flashcards on Python Programming : Advanced
Revise key concepts with interactive flashcards.
Try Computer Science Flashcards3 quizzes
Quizzes on Python Programming : Advanced
Test your knowledge with fun and engaging quizzes.
Try Computer Science Quizzes4 questions
Exam questions on Python Programming : Advanced
Boost your confidence with real exam questions.
Try Computer Science Questions27 exams created
Exam Builder on Python Programming : Advanced
Create custom exams across topics for better practice!
Try Computer Science exam builder27 papers
Past Papers on Python Programming : Advanced
Practice past papers to reinforce exam experience.
Try Computer Science Past PapersDiscover More Revision Notes Related to Python Programming : Advanced to Deepen Your Understanding and Improve Your Mastery
96%
114 rated
Python Programming : Advanced
Python Programming : Advanced
312+ studying
193KViewsJoin 500,000+ Leaving Cert students using SimpleStudy...
Join Thousands of Leaving Cert Students Using SimpleStudy to Learn Smarter, Stay Organized, and Boost Their Grades with Confidence!
Report Improved Results
Recommend to friends
Students Supported
Questions answered