0% found this document useful (0 votes)
2 views

Python unit 1

The document provides an overview of Python, highlighting its three numeric data types, interpreted nature, and object-oriented features. It details the Python development cycle, syntax rules for identifiers, and various data types including numbers, strings, lists, tuples, and dictionaries. Additionally, it covers operators in Python and includes examples of writing simple programs for user input and calculations.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Python unit 1

The document provides an overview of Python, highlighting its three numeric data types, interpreted nature, and object-oriented features. It details the Python development cycle, syntax rules for identifiers, and various data types including numbers, strings, lists, tuples, and dictionaries. Additionally, it covers operators in Python and includes examples of writing simple programs for user input and calculations.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Python Basics

 Python supports three numeric data types: “integer”, “float”, and “complex”.
 It is an *interpreted language*, meaning code is executed line by line, which differs
from compiled languages.
 Python is *object-oriented* and *high-level*, allowing for easier interaction with
users.
 It was created by Guido van Rossum during 1985 – 1990.

Features of Python –
 Easy to Learn
 Easy to read
 Easy to maintain
 Scalable
 GUI Programming

Traditional Development Cycle


Start
Startthe application
the application

Testthe
Start behaviour
application

Stop
Startthe
the application
application

Edit
Start theProgram
application

Recompile the code


Start the application

Relink the
Start theExecutable
application file

Python Development Cycle


Start
Startthe
the application
application

Testthe
Start Behaviour
application

Stopthe
Start application
application

Edit thethe
Start Program code
application
Python Syntax and Structure
Identifier –
 a name give to variables, function, class, module or other entities in program.
 Rules for naming –
 Starting from (a-z), (A-Z), or Underscore(_)
 The remaining letters can be letters, numbers, or underscore.
 Case sensitive.
 Cannot be reserved word – (have special meaning like false, true,
global and with etc.)

Indentation and Lines -


 It uses *indentation* instead of braces to define code blocks, which is crucial for
controlling the flow of execution.
 Block of codes are denoted by Indentation.

Variables and Data Types


 Variables in Python are *reserved memory locations* to store values, and their
types are dynamically assigned.
 Based on the data type of the variables, the interpreter allocates memory.
 You can locate integers, decimal, or char.
Python has several *standard data types* : used to define the operation
possible on them including –
 Numbers – (int, float, complex)
 Strings – (set of chartacters)
 Lists - (collection of elements)
 Tuples – (similar to list but immutable)
 Dictionaries – (key value pairs)

Operators in Python
Python includes various *operators* :
 Arithmetic operators - perform common mathematical
operations.

a=4
b=2
print(a+b)
print(a-b)
print(a*b)
print(a/b)
print(a%b)
print(a**b)
print(a//b)
 Comparison operators - are used to compare two values.

a=4
b=2
print(a==b)
print(a!=b)
print(a>b)
print(a<b)
print(a>=b)
print(a<=b)
 Logical operators - combine conditional statements.

a=2
print(a<5 and a<10) #output - true

a=5
print(a<1 and a<10) #output - false

 Assigment operstors - used to assign values to variables.


 Bitwise operators - used to compare binary numbers

5 -> 101

7 -> 111

a=5

b=7

print(a&b) #output – 5

print(a|b) #output - 7
Writing Python Programs

The video demonstrates how to write simple programs, such as

 adding two numbers and calculating the area of a circle.


a = int(input(“enter first element”)
b = int(input(“enter second element”)
c = a+b
print(“sum =”,c)

 Input functions are used to gather user data, which is often


converted to integers for calculations.

You might also like