WELCOM
T O O U R P R E S E N T A T I O N
E
PRESENTATION NO.10
Group members: Laiba
Maryam
Hamma
d
Abdul
Mana
n
Minahil
Salman
fatima
Ahmad
raza
INTRODUCTION
Presentation No .10
Topics:
• Introduction to python
• Operators , operation & comparisons
• Problem solving , repetition structure and pseudo codes
COMPUTER PROGRAM
A computer program is a set of instructions written in a
programming language that tells a computer what to do. Think of
it as a recipe for the computer to follow. These instructions are
processed by the computer to perform specific tasks,
such as:
• Performing calculations: From simple arithmetic to complex
mathematical equations.
• Processing data: Organizing, analyzing, and manipulating data.
• Controlling hardware: Interacting with devices like
printers, scanners, and robots.
• Running applications: Enabling the use of software
like word processors, web browsers, and games.
Who develop’s computer program?
A person who develops computer programs is called a programmer.
The programmer develops programs to instruct the computer how to
process data to convert into information. Programmer uses
programming languages or tools to write programs.
INTRODUCTION TO PYTHON
Definition:
A Python program is a sequence of instructions written in the Python
programming language that tells a computer what to do. Python is a
versatile, high-level programming language known for its simplicity
and readability. It's widely used for various applications, from web
development and data science to artificial intelligence and
automation.
PYTHON
Here's a simple Python program:
print("Hello, world!")
This program instructs the computer to print the message "Hello,
World!" on the screen.
CHARACTERISTICS OF PYTHON
• Readability: Python code is designed to be easy to read and understand, making
it a great language for beginners.
• Versatility: Python can be used for a wide range of applications, including web
development, data science, machine learning, and automation.
• Large community: Python has a large and active community of developers
who contribute to its growth and provide support.
• Standard library: Python comes with a rich standard library that provides
modules for various tasks, such as file I/O, network programming, and data
manipulation.
INDENTATION
• Basics of Indentation: Indentation is the leading
whitespace before any statement in Python.
Purposes:
• Improves readability.
• Helps in indicating a block of code.
Example:
char name = "Sam";
if (name == "Sam")
{ printf("Hello Sam!");}
C program
name = ‘Sam’ if name == 'Sam': print('Hello Sam’)
This highlights the use of indentation in Python to define code blocks. Unlike C,
which uses curly braces {} to group statements, Python relies on consistent
spacing (usually 4 spaces) to indicate the beginning and end of a code block.
This makes Python code more visually appealing and easier to understand.
WORKING OF INDENTATION
WITHOUT INDENTATION: WITH INDENTATION:
name = 'Sam’ name = 'Sam’
if name == 'Sam’: if name == 'Sam’:
print('Hello Sam’) print('Hello Sam’)
Else : Else:
print('Hello dude’) print('Hello dude’)
print('How are you?’) print('How are you?')
RULES FOR INDENTATION IN PYTHON
• Rule #1: Minimum one space is necessary to represent an indented
statement.
• Rule #2: The first line of Python code cannot have indentation.
• Rule #3: Indentation is mandatory to define a block of code .
• Rule #4: The number of spaces must be uniform.
CONTROL STRUCTURE IN PYTHON
• 2.if...else statement :
• 1.if statement :
age = int(input("enter your age"))
age = int(input("enter your
age")) if age > 18:
if age > 18: print("you can apply for license")
print("you can apply for else:
license") print("You can't apply ")
• 3. if-elif-else • nested if-else statement :
statement: if age >= 18: if nationality ==
"Pakistani": print("You are eligible
age = int(input("Enter your age: "))
to vote in Pakistan.")
if age < 18: else: print("You may be eligible
print("You are a minor.") to vote in your country of citizenship.")
else: print("You are not yet eligible to
elif age >= 18 and age < 65:
vote.")
print("You are an adult.")
else: print("You are a senior
citizen.")
CONTROL STRUCTURE IN PYTHON
Loops
1.while condition: Code to be executed repeatedly
Example: count = 0 while count < 5: print(count) count += 1.
2.For loop: Code to be executed for each item Iterating
Over a Range: You can use the range() function to generate a sequence of numbers:
for i in range(5): print(i) This will print numbers from 0 to 4:01234
0
1
2
3
4
INTRODUCTION TO PROGRAMMING BASICS
• Brief overview of:
Operators & Operands Variable
Comparison Logical & Boolean Operations
Conditional Statements
Order of Precedence
Importance of understanding these concepts in programming.
OPERATORS & OPERANDS
Operators: Symbols that represent computations (e.g., +, -, *, /).
Types of Operators:
Arithmetic Operators: +, -, , /,
Relational/Comparison Operators: ==, !=, >, <, >=, <=.
Assignment Operators: =, +=, -=, *=, /=, etc.
Logical operators: And ,Or & Not(&&, ||, !).
VARIABLE COMPARISON
• Purpose : Used to compare two values or variables
Relational operators: Check for conditions like equality and inequality
Equal to (==): - Checks if two values are the equal –
For example :If a==b (checks if a equals b)
Not equal (!=): -Checks if two values are not equal
Greater than (>) / Less than (<)
.Checks relative size.
Greater than or equal (>=) / Less than or equal (<=).
Application: Useful in decision-making within conditional statements.
LOGICAL & BOOLEAN OPERATIONS
• Logical Operators: Used to combine multiple conditions.
• AND (and): Both conditions must be true.
• OR (or): At least one condition must be true.
• NOT (not): Reverses the result of a condition.
• Boolean Values: True and False
• Use Cases: -Simplifies complex conditions in programming.
CONDITIONAL STATEMENTS
• Purpose: Allows the program to make decisions and execute code
selectively.
Basic structure
• if condition:-Executes code if the condition is true.
• If-Else Statement:-Executes one block of code if true, another if false.
• Nested Condition:-Used for multiple conditions.
• Switch Conditions: - Used to execute specific code based on a
variable’s value.
• If: • If/else:
if age > 18: if age > 18:
print("You are an adult.") print("You are an adult.")
else:
print("You are not an adult.")
• Nested if: • Switch:
if age > 18: match day:
if has _ ID: case 1: print("Monday")
print("You can vote.") case 2: print("Tuesday")
else: case _: print("Not a valid
print("You need an ID to vote.") day")
ORDER OF PRECEDENCE
• Definition:
The order in which operations are evaluated.
• Importance :
Ensures calculations are performed correctly.
Standard Precedence (PEMDAS):
•Parentheses () •Exponents ** •Multiplication/Division *, /, //,
%•Addition/Subtraction +, -•Relational Operators: <, <=, >, >= •Logical
Operators: not, and, or (in that order).
EXAMPLES AND APPLICATIONS
• Example 1:
Basic calculation with precedence:- 3 + 5 * 2 evaluates to 13
(multiplication before addition).
• Practical Applications: Decision-making in applications, data
validation, control flow.
EXAMPLES AND CODE DEMONSTRATIONS
• Code Examples demonstrating:
•Basic arithmetic and logical operations.
•Variable comparison with if-else statements.
•How precedence affects expression outcomes.
• Interactive Demonstration: If possible, show how different
operators interact.
PROBLEM SOLVING
• Problem Solving= The process of finding and implementing
solutions to overcome challenges or difficulties.
Procedure of Problem Solving
1.Identify the Problem:
What problem are you trying to solve?
2.Gather Information:
What do you already know about the problem?
3.Evaluate Solutions:
Which solution is the most practical?
PROCEDURE OF PROBLEM SOLVING
4. Choose a Solution:
Pick the best solution and make a plan to implement it.
5. Take Action:
Put your plan into action.
6. Evaluate the Results:
Did your solution work? If not, what can you do differently next time?
PYTHON WITH DECISION MAKING
1) Problem Solving in Python with Decision Making
Decision making in Python involves making choices based on conditions using control
structures
like if, elif, and else.
Steps for Decision Making Problems
1.Input
2.Calculate Decision
3.Output
PYTHON WITH SEQUENTIAL
STRUCTURE
2) Problem Solving in Python with Sequential Structure
A sequential structure in Python means the code executes step by
step, in the order it is written.
Steps
1.Input
2.Process
3.Output
PYTHON WITH repetitive structure
3) Problem Solving in Python using Repetitive
Structures
A repetitive structure involves looping to repeat actions. Python provides
loops like
for and while to solve such problems.
Steps
1.Input
2.Repetition
3.Output
PSEUDOCODE
It is an informal way to describe an algorithm using plane
language. It helps you without syntax.
Example:
Input Number 1
Input Number 2
Input Number 3
If Number 1 >= Number 2 and Number 1 >= Number 3
Print "Largest number 1"
Else if Number 2 >= Number 1 and Number 2 >= Number 3
Print "Largest number 2" Else
Print "Largest number 3"
FLOWCHART
Start
Input no 1 If
No 1 > 3 Yes Print
Input no 2
And “Larger is
Input no 3
No 1 > 3 no 1”
No
If
Print Yes No 2 > 1 No Print
“Larger is And “Larger no End
no 2” No 2 > 3 is 3”