0% found this document useful (0 votes)
11 views18 pages

Introduction to Python Programming

Python is a versatile, high-level programming language created by Guido van Rossum in 1991, known for its readability and simplicity. It can be used for various applications including web development, software development, and data analysis. The document also covers basic syntax, variables, identifiers, data types, and operators in Python.
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)
11 views18 pages

Introduction to Python Programming

Python is a versatile, high-level programming language created by Guido van Rossum in 1991, known for its readability and simplicity. It can be used for various applications including web development, software development, and data analysis. The document also covers basic syntax, variables, identifiers, data types, and operators in Python.
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 Python

What is Python?
 Python is a popular programming language & it is versatile,
high-level programming language known for its readability and
simplicity, designed for ease of learning and use.

 It was created by Guido van Rossum, and released in 1991.

 It is used for:
• web development (server-side),
• software development,
• mathematics,
• system scripting.
• Etc.
What can Python do?
•Python can be used on a server to create web applications.
•Python can be used alongside software to create workflows.
•Python can connect to database systems. It can also read and modify files.
•Python can be used to handle big data and perform complex mathematics.
•Python can be used for rapid prototyping, or for production-ready software development.

Why Python?
•Python works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc).
•Python has a simple syntax similar to the English language.
•Python has syntax that allows developers to write programs with fewer lines than some other
programming languages.
•Python runs on an interpreter system, meaning that code can be executed as soon as it is written. This
means that prototyping can be very quick.
•Python can be treated in a procedural way, an object-oriented way or a functional way.
Python Basic Syntax

• There is no use of CURLY BRACES or SEMICOLONS python programming language.


• It is a English-like language.

Python First Program

Print(“Hello World”)
What is Python Variable?
•It’s a storage location that holds a value.

•x=5

•Here " x " is a variable & " 5 " is Identifier.

Creating a Python Variable?


•A variable is created the moment you first assign a value to it.

x=5
y = "John"
print(x)
print(y)
Programming

Translator
(Compiler / Interpreter)

Code
Machine
What is Compiler ?
•A compiler is a software program that translates
code written in a high-level programming language
(like C++, Java, or Python) into machine code or
bytecode, which a computer can directly understand
and execute.

What is an Interpreter ?
•An interpreter is a program that executes code
directly, line by line, during runtime, translating
high-level instructions into machine code.
Comments In Python

# Single Line Comment

“““
Multi
Line
Comment

”””
Identifiers
An identifier in Python is a name used to identify a variable, function, class, module, or other object. It serves as a
unique label that allows you to reference and manipulate these entities within your code.

Types of Identifiers
1. Variable Identifiers:
•These are names given to memory locations that store data values.
•Example: age, name, total_amount.

2. Function Identifiers:
•These are names assigned to functions, which are blocks of code designed to perform a specific task.
•Example: calculate_sum(), display_message(), get_user_input().

3. Class Identifiers:
•These are names representing user-defined data types that encapsulate data and methods.
•Example: Person, Car, ShoppingCart.
4. Module Identifiers:
•These are names given to files containing Python code that can be imported and reused.
•Example: math, os, datetime.

5. Special Identifiers:
•Identifiers that start and end with two underscores, such as __init__ or __str__, have a special meaning in
Python and are often used for language-defined methods.

Rules For Identifiers


• Identifiers can be combination of uppercase and lowercase letters, digits or an underscore (_). So
myVariable , variable_1, variable_for_print all are valid python identifiers.
• An Identifier can not start with digit. So while variable1 is valid , 1variable is not valid.
• We can’t use special symbols like !, #, @, %, $ etc in our Identifier.
• Identifier can be of any length.
Python Character Set

• Letters – A to Z , a to z
• Digits – 0 to 9
• Special Symbols - + * - / etc.
• Whitespace – Blank Space, tab, newline, formfeed
• Other characters – Python can process all ASCII and Unicode characters as part of data or literals.
Data Types

• Integers
• String
• Float
• Boolean
• None
Keywords

• Keywords are reserved words in python.

and else in return

or except is True

assert finally lambda try

break False nonlocal with

class for None while

continue from not yield

def global or
del if pass
elif import raise
Print Sum

a = 29
b=3
sum= a + b

print(sum)
Types Of Operators
An operator is a symbol that performs a certain operation between operands.

• Arithmetic Operators (+ , - , * , / , %, ** )

• Relational / Comparison Operators (==, != , > , < , >=, <= )

• Assignment Operators ( = , +=, -=, *=, /=, %=, **= )

• Logical Operators ( not, and , or )


Type Conversion

a , b = 1, 2.0
sum = a + b

#error
a , b = 1 , “2”
sum = a + b
Type Casting

a , b = 1,“2”
c = int(b)
sum = a + c
Input in Python

input() statement is used to accept values (using keyboard) from user

input() # result for input() is always a str


int ( input() ) # int
float ( input() ) # float

You might also like