0% found this document useful (0 votes)
4 views48 pages

Chapter 6 - Python Programming

This document provides an overview of Python programming, including its definition, types of programming languages, and the importance of learning programming. It covers key concepts such as object-oriented programming, data types, control flow, and basic Python syntax. Additionally, it discusses the role of translators in converting source code into machine code.

Uploaded by

sanvi.ganesh14
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)
4 views48 pages

Chapter 6 - Python Programming

This document provides an overview of Python programming, including its definition, types of programming languages, and the importance of learning programming. It covers key concepts such as object-oriented programming, data types, control flow, and basic Python syntax. Additionally, it discusses the role of translators in converting source code into machine code.

Uploaded by

sanvi.ganesh14
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

Unit 6

Python Programming
Learning Objective :
To understand what is computer programming and its use in our real world
To learn the different Translators
Differentiate Procedure oriented and object oriented programming
To learn different generation of programming
To learn the concepts of object oriented programming
How to design and program Python code.
●Any Programming language you have learned?
●How and Where?
Discussion ●Do you use Python Programming in your daily
activity anywhere?
Time

Starter
Overview
•Programming is the process of giving
instructions to a computer to perform specific
tasks.
•These instructions are written using a
What is programming language.
•The human-readable form of a program is
Programming? called source code.
•Computers only understand binary (0s and
1s), so we use programming languages to
communicate with them easily.

LO1: To understand what is computer programming and its use in our real world
●Develops logical thinking and problem-solving
skills.
Why Learn ●Helps automate tasks.
Programming
●Useful for creating games, apps, and websites.
?
●Python is one of the easiest and most powerful
programming languages for beginners.
Type Description Example
Closer to machine Machine Code /
Low-level
language like binary Binary language
Not completely easy,
Types of Mid-Level Assembly
use mnemonics
Language Easy to read and
Python, Java,
High-level understand by the
C++
programmer
Uses drag-and-drop
Visual Scratch, Blockly
blocks
Programming
languages
Find Who?

A B

AFL
●Computers operate in binary (on/off states).
●Machine language is written in binary.
●Assembly language and high-level languages
Machine (like Python) are converted into binary before
the computer executes them.
Language
•Binary (Base 2): Used by computers
Types of
•Octal (Base 8): Short form of binary
Number
•Decimal (Base 10): Human number
System of
system
Machine
•Hexadecimal (Base 16): Compact form
Language
used in programming
Number
Base Digits Used Example
System
Binary 2 0, 1 1010₂

Octal 8 0–7 157₈


Number Decimal 10 0–9 245₁₀
systems
Hexadecimal 16 0–9, A–F 2F₁₆
•Used by computers and digital devices.
Binary •Each binary digit (bit) can be 0 or 1.
Number •8 bits = 1 byte.
System •Computers use binary to represent everything
(Base 2) — numbers, letters, images, and sounds.
Example:
1010₂ = (1×8) + (0×4) + (1×2) + (0×1) = 10₁₀
Decimal •The system humans use every day.
Number •Has 10 digits (0–9).
System •Each digit has a place value (ones,
(Base 10) tens, hundreds, etc.)
Example:
345₁₀ = (3×100) + (4×10) + (5×1)
•Uses digits 0–7.
•Commonly used in older computer
Octal systems as a short form of binary.
Number
•Every 3 binary digits = 1 octal digit.
System
Example:
(Base 8)
Binary 110010₂ → Octal 62₈
(Split binary into groups of 3 from right → 110
010 → 6 2)
•Uses digits 0–9 and letters A–F
(A=10, B=11, … F=15).
Hexadecima •Used in computer programming
l Number and memory addresses.
System •Every 4 binary digits = 1
(Base 16)
hexadecimal digit.
Example:
Binary 11110000₂ → Hexadecimal F0₁₆
●A translator is a program that converts source
code into machine code.
●Generally, there are three types of translator:
● Compilers
● Interpreters
Translators ● Assemblers

Lo2:To learn the different Translators


Translators
AFL
AFL : Answer
Differences
between
Procedural and
Object-Oriente
d
Programming

LO3: To learn different types of programming : Procedure oriented and object oriented programming
Identify the programming

A B

AFL
●The OOPs concepts include the following:
● Object
● Class
OOPs ● Inheritance
Concepts ● Polymorphism
● Abstraction
● Encapsulation

LO4: To learn the different concepts of object oriented programming


ABSTRACTION
ENCAPSULATION POLYMORPHISM

INHERITANCE MODULARITY
A C

Identify the concepts

AFL
●Python is a high-level, interpreted, and
object-oriented programming language.
●Created by Guido van Rossum in 1991.
Python
●Known for its simplicity and readability.
Programming

●Fun fact: Named after the comedy show


Monty Python’s Flying Circus!

LO5: How to design and program Python code


•Easy to learn and write
Features of •Open-source and free
Python •Platform-independent
programming •Large library support
•Widely used for web apps, AI,
games, and automation
•Variable: A container to store data (e.g.,
name = "Ava")

•Data Types: Types of values a variable


can hold
•String ("Hello")
•Integer (5)
Basic Terms •Float (3.14)
•Boolean (True or False)
•Operators: Symbols that perform
operations (+, -, *, /)
•Input/Output: Taking user input and
displaying output
● Tokens or lexical units are the smallest fractions in the python
programming.
Tokens ● A token is a set of one or more characters having a meaning
together.
Type of tokens
● A Python variable is a symbolic name that is a reference
or pointer to an object.
● Defined rules for declaring variable :
● Variable shouldn't begin with any numerical digit and hence,
the first character must be either an underscore or an alphabet.
● Variable are case-sensitive and hence, both lowercase and
Variables uppercase letters are distinct.
● The length of identifiers shouldn't be more than 31 characters.
● Commas and blank spaces are not allowed while declaring an
identifier.
● Also, the most important rule is that we can't use keywords as
identifiers because keywords in python language are reserved
words for special purposes only.
● An operator is a symbol that will perform mathematical
operations on variables or on values. Operators operate
on operands (values) and return a result

Operators ● Python has seven types of operators that you can use:
● Arithmetic Operators
● Relational Operators
● Assignment Operators
● Logical Operators
●A program’s control flow is the order in which
the program’s code executes. The control flow
of a Python program is regulated by conditional
Control Flow statements, loops, and function calls.
of Program ●Python has three types of control structures:
● Sequential - default mode
● Selection - used for decisions and branching
● Repetition - used for looping, i.e., repeating a piece
of code multiple times
Java vs
python coding
Program 1

AFL
Program 2
Program 3
Program 4
●A data type is an attribute associated with a
piece of data that tells a computer system how to
interpret its value.
Datatype
●Understanding data types ensures that data is
collected in the preferred format and the value
of each property is as expected.
Numeric Types:
●int: (Integer) Represents whole numbers (e.g., 1, 2,
-10).
●float: Represents numbers with decimal points (e.g.,
3.14, -0.5).
●double: Represents complex numbers (e.g., 2
Types of .08776565+ ).
Datatypes Text Type:
●str: (string) Represents a sequence of characters
(e.g., "Hello, World!").
Boolean Type:
●bool: Represents True or False values.
x=5
y = 10
print( “x=“ ,x)
Print(“y=“,y)
Predict the
output of the x=10,y=5
Program temp = x
x=y
y = temp
print( “x=“ ,x)
Print(“y=“,y)
Online
Platform for ● [Link]

python coding

You might also like