Unit 5: Introduction to Python
● When you give a set of instructions to computer using a
programming language, it is called a program.
● A collection of programs is reffered to as software.
● The process of writing code in a systematic and logical
order is called programming.
● An algorithm is a set of sequential steps to solve any
logical or mathematical problem.
● Characteristics of Algorithms:
# Provides clear instructions.
# Muat have only one meaning.
# Should not be too long.
# Have well-defined input and output to match the
desired result.
# Take care of the input, processing and output of each
step.
# Must terminate after a finite number of steps.
# Have step-by-step instructions.
● A flowchart is a digrammatic representation of the steps
of an algorithm, which are used for solving a particular
[Link] helps to find and remove errors that appears
during programming.
● The three types of control flow statements
are,i.e.,sequencing, branching (selection) and looping
(interaction).
● Characteristic of flowcharts:
# Must have a clear start and end.
# Must flow in logical order.
# Used accoeding to rules.
# Shoud be short, clear and readable.
# Should have suitable and common keywords.
# Linked using flow lines to show the direction of the
data flow.
● A language that consists of a set of instructions that is
clearly understood by the computer is known as the
computer programmind language.
● Python is a high-level programming language.
● Developed by Guido van Rossum.
● Intergrated Development and Learning Enviroment
(IDLE).
● Python is also called an interperated language.
● Python is general-purpose, portable, freeware and a
powerful programming language.
● Features of python:
Python is a powerful, high-level, and versatile
programming language known for its simple, readable
syntax and extensive ecosystem of libraries.
Key features of Python include:
# Simple & Easy to Learn.
# Interpreted Language.
# Dynamically Typed.
# High-Level Language.
# Object-Oriented & Multi-Programming.
# Large Standard Library & Third-Party Ecosystem.
# Free & Open-Source.
# Cross-Platform & Portable.
# Extensible & Integrated.
# Automatic Memory Management.
# Interactive Mode.
● Applications of Python:
# Web Development.
# Data Science and Analytic.
# Artificial Intelligence (AI) and Machine Learning (ML).
# Automation and Scripting.
# Software Development.
# Desktop Applications.
# Scientific and Numeric Computing.
# Game Development.
# Business Applications.
# Image and Text Processing.
● Summary of Differences of interactive and
script mode:
Aspect Interactive Mode Script Mode
Executio The entire script at
Line-by-line
n Style once
Learning, testing Complete programs,
Use
snippets, quick automation, large
Cases
checks projects
Feedbac Immediate for After the entire script
k each line runs
Code No (commands are Yes (code is saved in a
Persiste not saved) .py file)
nce
● .py is the extension of pythons file.
●A character set can be defined as a set of valid
characters.
●A line of code that you write to carry out a task is called
a statement.
● When a statement contains operands and operators in a
systematic manner, it is reffered to as an expression.
●A single-line statement is a complete instruction written
on one line of code, while a multi-line statement is an
instruction that spans across several lines, often used for
clarity or when the code is too long to fit on a single line.
Single-line Statement:
# Definition: A command or instruction that begins and
ends on the same line.
# Purpose: Used for brevity and clarity when the
instruction is simple or short.
# Examples:
x = 10
print("Hello, world!")
if a > b: print("A is greater")
Multi-line Statement:
# Definition: A single, logical command or instruction
that is written across two or more physical lines of code.
# Purpose: Often used to improve readability, especially
for complex expressions, long function definitions, or data
structures like lists and dictionaries that contain many items.
# Examples:
In Python, you can use parentheses for implicit line
continuation:
total = (item_one + item_two + item_three )
● Two ways to write multi-line statement:
#