0% found this document useful (0 votes)
2 views61 pages

Python Lesson 1

The document outlines a foundational course on Python programming, covering essential topics such as computer programming anatomy, Python syntax, variables, and data types. It emphasizes the importance of readability in code, the use of high-level programming languages, and the practical applications of Python in various domains. Additionally, it provides guidelines on writing clean code and understanding variable management in Python.

Uploaded by

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

Python Lesson 1

The document outlines a foundational course on Python programming, covering essential topics such as computer programming anatomy, Python syntax, variables, and data types. It emphasizes the importance of readability in code, the use of high-level programming languages, and the practical applications of Python in various domains. Additionally, it provides guidelines on writing clean code and understanding variable management in Python.

Uploaded by

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

Introduction to Computer Programming & Python Basics

Module 1: Complete Zero-to-Hero Foundational Course

Python Programming

Ellys Academy

July 2026

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 1 / 61


Course Breakdown: 4 Core Columns

1 Part 1: The Anatomy of Computer Programming

2 Part 2: Python Syntax Foundations

3 Part 3: Variables and Dynamic Data Typing

4 Part 4: Math Operations and String Manipulations

5 Part 5: Interactive Inputs Data Type Transformations

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 2 / 61


Part 1: The Anatomy of Computer Programming
Understanding How Machines Think

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 3 / 61


What Exactly is Programming?

At its core, programming is telling a computer exactly what to do.


Computers are incredibly powerful, but they are also completely uncreative. They require
step-by-step guidance.
A program is a set of sequential commands written in a language the machine understands.
Think of it like writing a kitchen recipe: if you skip a step or state it poorly, the cake is ruined.

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 4 / 61


The Machine Language vs. Human Language Gap

Computers speak in Binary Code (1s and 0s) representing electrical signals.
Humans communicate via spoken, high-level vocabulary.
Writing raw binary code is slow, incredibly complex, and prone to extreme human error.
The Solution: We write in intermediate High-Level Programming Languages that look closer
to human speech, then translate them down for the machine.

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 5 / 61


Compilers vs. Interpreters: The Translators

High-level human code is converted into binary execution sets using one of two strategies:

The Compiler Paradigm


Translates the entire program all at once into a separate file before running it (e.g., C++, Java). Fast
execution, slow modification cycles.

The Interpreter Paradigm


Translates and runs the written lines of code sequentially one row at a time. Allows immediate
modifications and makes bug tracing straightforward.

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 6 / 61


Enter Python: History and Creation

Python was created by a developer named Guido van Rossum and first released in 1991.
It was explicitly engineered with a primary philosophy: Readability counts.
It is an interpreted, high-level, object-oriented language.
Fun Fact: The language is not named after the snake. It was named after the British comedy show
Monty Python’s Flying Circus.

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 7 / 61


The Zen of Python: Key Design Pillars

If you type import this into a Python window, it reveals its core design guidelines:
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Flat is better than nested.
Readability matters.

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 8 / 61


Where is Python Used in the Real World?

Python is currently a top choice across modern computing ecosystems:

Domain Popular Frameworks / Libraries


Data Science & Analytics Pandas, NumPy, Matplotlib
Artificial Intelligence TensorFlow, PyTorch, OpenAI API
Web Backend Applications Django, Flask, FastAPI
Automation & Scripting Selenium, BeautifulSoup

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 9 / 61


Setting Up Your Sandbox: IDLE, IDEs, and Notebooks

To write and execute Python scripts, you need a environment tool:


Interactive Shell (REPL): Evaluates short individual script code segments instantly.
Script Mode Files (.py): Used to save complete, multi-line programs.
IDEs (Integrated Development Environments): Feature-rich apps containing debugging tools
and color syntax systems (e.g., VS Code, PyCharm).
Cloud Notebooks: Browser-based tools that blend live code blocks with formatted annotations
(e.g., Google Colab).

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 10 / 61


Part 2: Python Syntax Foundations
The Basic Rules of Writing Code

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 11 / 61


Dissecting Your First Script: Hello World

Let’s break down this classic introductory command:


print ( " Hello , World ! " )

print is a built-in function that sends an output back to the user via the console.
The parenthesis () tell Python to evaluate or activate the function tool.
The text sitting inside the parentheses is the input argument.
Double quotes indicate that the text is raw text data, which programmers call a String.

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 12 / 61


Case Sensitivity Constraints

Python treats uppercase and lowercase characters as completely unique items.

print ( " Hello " ) # This works p e r f e c t l y !


Print ( " Hello " ) # ERROR : N a m e E r r o r : name ’ Print ’ is not defined
PRINT ( " Hello " ) # ERROR : N a m e E r r o r : name ’ PRINT ’ is not defined

Key Rule
All built-in Python core function statements use lowercase formatting.

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 13 / 61


The Quotation Mark Guide

Strings can be wrapped in single or double quotes, but they must always match up cleanly.

print ( ’ This is correct . ’)


print ( " This is also correct . " )
print ( " Mixed quotes will cause an error ’) # SyntaxError

Nesting Quotes
If your text contains a single quote, wrap the outer borders in double quotes:
print ( " It ’s a beautiful day for programming ! " )

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 14 / 61


The Whitespace Indentation Philosophy

In languages like C++ or Java, code groups sit inside curly brackets {}.
Python eliminates brackets and uses Whitespace Indentation to organize code blocks instead.
Standard scripts must always start at the absolute left edge of the file column.
Accidentally hitting the spacebar at the start of a line throws an error.

Indentation Error Example


print ( " Indented line error " )
# Throws : I n d e n t a t i o n E r r o r : u n e x p e c t e d indent

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 15 / 61


Documenting Code Using Comments

Comments are notes written in code files that Python purposefully ignores when running the script.
Single Line Comments: Begin using the hash symbol (#).
Inline Comments: Sit right next to live code blocks to clarify specific inputs.

Code Comments Example


# This code prints a daily status check
print ( " System Active " ) # Core alert s t a t e m e n t

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 16 / 61


Multi-line Blocks & Docstrings

To write a longer comment across multiple lines, you can use independent hash marks or Docstrings
(triple quotes):

# Line one note


# Line two note
# Line three note

"""
This is a multi - line string block
that acts as a long comment .
"""
print ( " Docstring demo complete " )

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 17 / 61


Advanced print() Settings

You can separate values inside a print statement using a comma. By default, this adds a space between
the values.

print ( " Score : " , 100) # Output : Score : 100

Modifying Separators
Use the sep argument to change how items are separated, or the end argument to keep the next print
statement on the same line:
print ( " Apple " , " Banana " , sep = " -" ) # Output : Apple - Banana
print ( " Hello " , end = " " )
print ( " World " ) # Output : Hello World

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 18 / 61


Syntax Checkpoint: MCQ 1

Question: Which of the following code options will execute without errors?

A print(Hello World)
B # print("Test Data")
C print("Good Morning")
D print("I’m learning Python")

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 19 / 61


Syntax Checkpoint: MCQ 1 (Answer)

Correct Answer: D
Option A is missing quotes. Option B is a comment, so it won’t execute code outputs. Option C has an
indentation space error. Option D correctly nests a single quote inside double quotes.

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 20 / 61


Coding Challenge: Output Formatting

Task Requirement
Write a 3-line Python script that outputs a basic text art layout exactly like the one below. Ensure you
manage the spacing correctly:

*
***
*****

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 21 / 61


Coding Challenge: Output Formatting (Solution)

Correct Script Solution


print ( " * " )
print ( " *** " )
print ( " ***** " )

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 22 / 61


Part 3: Variables and Dynamic Data Typing
Storing and Classifying Memory Values

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 23 / 61


What is a Variable?

A variable is a named storage location in the computer’s memory.


Think of it like a storage box: you write a clear label on the outside and place data inside it.
Values are assigned using the assignment operator (=).

Assignment Directionality
Data flows from the right-hand side of the equals sign directly into the named variable on the left:
score = 2500 # The value 2500 is stored inside v ar i a b l e ’ score ’

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 24 / 61


Variables Can Change Over Time

Variables are called ”variable” because the data they hold can vary or change while the program runs.

current_level = 1
print ( current_level ) # Output : 1

current_level = 2 # The old value is o v e r w r i t t e n in memory


print ( current_level ) # Output : 2

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 25 / 61


Variables are Pointers, Not Math Equals

The assignment operator (=) doesn’t mean ”algebraically equal to.” It means ”store the result of the
right side into the left variable.”

x = 10
x = x + 5 # This is n o n s e n s e in algebra , but p e r f e c t l y valid in code !
print ( x ) # Output : 15

Python calculates the right side first (10 + 5 = 15) and updates the variable x with that new total.

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 26 / 61


Rules for Naming Variables

Python enforces strict rules for variable names. Violating these will crash your program:
1 Must start with a letter (a–z, A–Z) or an underscore character ( ).
2 Cannot start with a number.
3 Can only contain alphanumeric characters and underscores (a-z, 0-9, ).
4 Cannot contain spaces.
5 Cannot use Python’s reserved words (keywords like print, if, True).

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 27 / 61


Evaluating Variable Names

Let’s analyze what makes a variable name valid or invalid:

Variable Name Status Reason for Status


user phone Valid Follows standard naming rules.
temp Valid Starting with an underscore is allowed.
3rd place Invalid Cannot start with a number.
account$ Invalid Special characters like $ are banned.
user name Invalid Spaces are not allowed inside names.

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 28 / 61


Industry Best Practices: Writing Clean Code

While your code might run technically fine with names like x1, x2, or abc, writing clean code means
using descriptive, readable names:
Descriptive: Use names like elapsed time seconds instead of just t.
Snake Case: For multi-word variables, write everything in lowercase and connect words with
underscores (e.g., daily step count).
Camel Case: Capitalize the start of every word except the first one (e.g., dailyStepCount). This
style is common in JavaScript, but Snake Case is preferred in Python.

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 29 / 61


The Concept of Data Types

Data types define what kind of value a variable is holding. This classification tells Python how much
memory to allocate and what operations are valid for that specific data.
You can add two numbers together mathematically.
Adding two text strings together chains them into one word instead.
Python uses Dynamic Typing, meaning you don’t have to declare a variable’s data type manually.
The interpreter figures out the type automatically based on the assigned value.

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 30 / 61


The 4 Core Primitive Data Types

Here are the foundational data types you will use constantly in Python:
Integer (int): Whole numbers without decimals (e.g., 14, -500).
Float (float): Decimal numbers used for precise tracking (e.g., 3.14159, -0.004).
String (str): Text characters enclosed in quotation marks (e.g., "Suveer", ’123’).
Boolean (bool): Logical flags that can only be either True or False.

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 31 / 61


Deep Dive: Integers vs. Floats

Even if numbers look similar, adding a decimal point completely changes how Python treats them
behind the scenes:

a = 5 # This is an Integer ( int )


b = 5.0 # This is a Float ( float )

Integers have infinite precision in Python—they can grow as large as your computer’s memory
allows.
Floats are stored using double-precision binary formats. This can sometimes lead to tiny tracking
discrepancies (e.g., 0.1 + 0.2 might evaluate to 0.30000000000000004).

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 32 / 61


Deep Dive: Booleans

Boolean variables are used to track true/false conditions and control the logical flow of programs.

is_logged_in = True
h as _p as s ed _t es t = False

Capitalization Warning
The first letter of a Boolean value must be capitalized. Writing true or false in lowercase will throw a
compilation error.

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 33 / 61


Inspecting Variables Using type()

If you’re ever unsure what data type a variable is currently holding, you can verify it using the built-in
type() function:

x = 42
print ( type ( x ) ) # Output : < class ’ int ’>

y = " 42 "
print ( type ( y ) ) # Output : < class ’ str ’>

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 34 / 61


Multiple Assignment Shortcuts

Python allows you to create and assign values to multiple variables in a single line of code:

# A s s i g n i n g unique values to i n d i v i d u a l v a r i a b l e s
name , age , gpa = " Adhi " , 16 , 3.9

# A s s i g n i n g the exact same value to m u l t i p l e v a r i a b l e s at once


score_a = score_b = score_c = 0

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 35 / 61


Variables Checkpoint: MCQ 2

Question: What data type classification will the variable result receive after running this script?
value = " 9.99 "
result = value

A int
B float
C str
D bool

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 36 / 61


Variables Checkpoint: MCQ 2 (Answer)

Correct Answer: C
Because the value "9.99" is enclosed in quotation marks, it is initialized as a String data type.
Assigning it to another variable passes that String data type along.

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 37 / 61


Variables Checkpoint: MCQ 3

Question: Which of the following is a valid variable assignment statement in Python?

A 100 = high score


B high score == 100
C high score = 100
D high-score = 100

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 38 / 61


Variables Checkpoint: MCQ 3 (Answer)

Correct Answer: C
Option A attempts to store a variable inside a raw number, which is impossible. Option B uses a
comparison check instead of an assignment. Option D uses a hyphen, which throws a syntax error.
Option C is the correct variable assignment structure.

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 39 / 61


Coding Challenge: Variable Swapping

Task Requirement
You have two variables: a = 5 and b = 10. Write a script that swaps the values stored inside them, so
that a ends up holding 10 and b holds 5.

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 40 / 61


Coding Challenge: Variable Swapping (Solution)

The Standard Temporary Box Strategy


a = 5
b = 10
temp = a # Store the value of ’a ’ safely in a t e m p o r a r y v a r i a b l e
a = b # Update ’a ’ with the value of ’b ’
b = temp # Update ’b ’ with the value saved in the t e m p o r a r y v a r i a b l e

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 41 / 61


Coding Challenge: The Pythonic Swap Shortcut

While the temporary variable approach works in almost every programming language, Python offers an
elegant one-line shortcut for swapping variables:

One-Line Swap Solution


a = 5
b = 10
a, b = b, a # Values are u n p a c k e d and swapped i n s t a n t l y in memory !
print ( a ) # Output : 10
print ( b ) # Output : 5

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 42 / 61


Part 4: Math Operations and String Manipulations
Performing Calculations and Processing Text

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 43 / 61


Standard Arithmetic Operators

Addition (+): Adds values together (10 + 5 = 15).


Subtraction (-): Subtracts values (10 - 5 = 5).
Multiplication (*): Multiplies values (10 * 5 = 50).
Standard Division (/): Divides values (10 / 5 = 2.0).

Division Data Rule


Standard division using the forward slash (/) always returns a Float data type, even if the numbers
divide perfectly.

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 44 / 61


Advanced Math Operators

Floor Division (//): Divides numbers and rounds down to the nearest whole integer, cutting off
any decimal remainder.
Modulo (%): Divides numbers and returns only the remainder left over from that division.
Exponentiation (**): Raises the first number to the power of the second number.

Advanced Arithmetic Examples


print (7 // 2) # Output : 3 ( Decimal 0.5 is cut off )
print (7 % 2) # Output : 1 (2 goes into 7 three times , with 1 left over )
print (2 ** 3) # Output : 8 (2 raised to the power of 3)

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 45 / 61


The Order of Operations Rule (PEMDAS)

When evaluating complex expressions, Python follows standard mathematical order rules:
1 Parentheses ()
2 Exponents **
3 Multiplication * and Division /, //, % (evaluated from left to right)
4 Addition + and Subtraction - (evaluated from left to right)

Order of Operations Example


calculation = 5 + 2 * 10 / (2 ** 2)
# Step 1: P a r e n t h e s e s and e x p o n e n t -> 5 + 2 * 10 / 4
# Step 2: M u l t i p l i c a t i o n and d i v i s i o n -> 5 + 20 / 4 -> 5 + 5.0
# Step 3: A d d i t i o n -> 10.0

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 46 / 61


Augmented Assignment Shortcuts

When modifying an existing variable, you can use shorthand operators to keep your code concise:

x = 10

# The s t a n d a r d long form :


x = x + 5

# The clean s h o r t c u t form :


x += 5 # Adds 5 to ’x ’ i n s t a n t l y

This shorthand syntax works with all arithmetic operators: -=, *=, /=, %=.

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 47 / 61


String Manipulation: Concatenation

When you use the plus operator (+) with String text variables, it glues the strings together into a single
phrase. This process is called Concatenation.

first_word = " Python "


second_word = " Coding "

full_phrase = first_word + second_word


print ( full_phrase ) # Output : P y t h o n C o d i n g

# To add a natural space between words , include it e x p l i c i t l y :


better_phrase = first_word + " " + second_word
print ( better_phrase ) # Output : Python Coding

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 48 / 61


String Manipulation: Multiplication

Using the multiplication asterisk (*) with a String and an Integer repeats that text value a set number
of times.

laugh = " Ha "


mega_laugh = laugh * 4
print ( mega_laugh ) # Output : H a H a H a H a

divider_line = " -" * 20


print ( divider_line ) # Output : - - - - - - - - - - - - - - - - - - - -

Operation Type Error


Attempting to add a number directly to a text string (e.g., "Age: " + 16) will cause a type error.
You must convert the data types first.

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 49 / 61


Operations Checkpoint: MCQ 4

Question: What will be the console output of running the following script?
value = 15 % 4
print ( value ** 2)

A 9
B 3
C 16
D 25

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 50 / 61


Operations Checkpoint: MCQ 4 (Answer)

Correct Answer: A
First, the modulo operation is evaluated: 4 goes into 15 three times with a remainder of 3 (15 % 4 =
3). Next, the exponentiation operation squares that remainder value: 3 ** 2 = 9.

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 51 / 61


Operations Checkpoint: MCQ 5

Question: What will be the console output of running the following script?
word = " Go " + " ! " * 2
print ( word )

A Go!Go!
B Go!!
C Go!
D Error

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 52 / 61


Operations Checkpoint: MCQ 5 (Answer)

Correct Answer: B
Following the order of operations, multiplication runs before addition. The exclamation mark string is
duplicated first ("!" * 2 = "!!"), then it is concatenated with the starting text to create "Go!!".

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 53 / 61


Part 5: Interactive Inputs & Data Type
Transformations
Creating Dynamic, User-Driven Programs

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 54 / 61


Accepting Interactive User Data via input()

To build programs that react dynamically to users, we need a way to capture input. The built-in
input() function pauses your script and waits for the user to type text into the console.

favo rite_col or = input ( " What is your favorite color ? " )


print ( " You chose : " , favorite _color )

The text inside the input() function parentheses acts as a Prompt, displaying guidance instructions
for the user.

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 55 / 61


The Crucial input() Data Type Rule

Important Technical Behavior


The data captured by the input() function is always processed as a String data type, even if the user
types a clean number.

Consider this scenario:


user_input = input ( " Enter a number : " ) # User types 10
result = user_input + 5 # Throws : T y p e E r r o r

Because
useri nputisstoredasthetextstring "10"insteadoftheactualnumber 10, Pythoncrasheswhenyoutrytoaddittoamat

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 56 / 61


Data Type Casting (Explicit Conversion)

To fix type mismatch issues, we use Type Casting functions to explicitly convert variables from one
data type to another:
int(x): Converts value x into an Integer number.
float(x): Converts value x into a decimal Float number.
str(x): Converts value x into a text String.

Type Casting Fix Example


raw_input = input ( " Enter a number : " ) # C a p t u r e s string "10"
clean_number = int ( raw_input ) # C o n v e r t s it to integer 10
result = clean_number + 5 # E v a l u a t e s m a t h e m a t i c a l l y to 15

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 57 / 61


Streamlining Code with Nested Functions

Instead of capturing input and casting it across two separate lines of code, you can wrap the functions
inside each other to do it all at once:

Nested Input Casting


# Capture and i m m e d i a t e l y cast to an integer
user_age = int ( input ( " Enter your age : " ) )

# Capture and i m m e d i a t e l y cast to a float


product_price = float ( input ( " Enter product price : " ) )

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 58 / 61


Hour 2 Lab: Practical Application Workshop

Now it’s time to build a real program. Work through this capstone project inside your code editor
window:

Project Requirements: The Restaurant Bill Calculator


Write a complete Python script that calculates the final total for a restaurant bill. The program must:
1 Ask the user for the subtotal amount of the food bill.
2 Ask for the target tip percentage rate they want to leave (e.g., 15).
3 Calculate the tip amount based on that percentage.
4 Calculate a flat 8% sales tax on the initial subtotal.
5 Add the tip and tax back to the subtotal to find the final bill total.
6 Print a summary message showing the calculated tip, tax, and final amount.

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 59 / 61


Capstone Project Walkthrough Solution
Here is a complete, step-by-step solution for the Restaurant Bill Calculator program:

Calculator Program Script


# Step 1: Capture user inputs with a p p r o p r i a t e casting
subtotal = float ( input ( " Enter food subtotal amount : " ) )
tip_percent = float ( input ( " Enter target tip percentage : " ) )

# Step 2: Perform the c a l c u l a t i o n steps


tip_amount = subtotal * ( tip_percent / 100)
tax_amount = subtotal * 0.08
final_total = subtotal + tip_amount + tax_amount

# Step 3: Print the summary output


print ( " --- Bill Summary ---" )
print ( " Base Subtotal : " , subtotal )
print ( " Tip Added : " , tip_amount )
print ( " Tax Added : " , tax_amount )
print ( " Final Balance : " , final_total )

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 60 / 61


Session Wrap-Up & Homework

Core Takeaways:
Variables hold changing values in memory using dynamic typing.
Python uses specific math operators for operations like finding division remainders (%).
User inputs are captured as strings and must be cast before performing calculations.

Homework Assignments:
Task 1: Write a program that takes a temperature input in Celsius and converts it to Fahrenheit
using the formula: F = (C × 9/5) + 32.
Task 2: Write a script that takes a total number of minutes from the user and breaks it down into
hours and remaining minutes (Hint: Use floor division // and modulo %).

Next Lesson Topic: Control Flow Structures—Conditional logic decisions (if, elif, else) and
relational comparison operations.

Python Programming (Ellys Academy) Python Basics: Module 1 July 2026 61 / 61

You might also like