SlideShare a Scribd company logo
1 of 58
MODULE : 1
Data types, Operator and expression, input and output statements.
Control structure – selective and Repetitive structure
What is Python
It is a high level programming language and interpreted program
language, we can execute the programs with less line of codes.
Syntax : print(“hello world”)  hello world
What is interpreter?
• Interpreters are the computer program that will convert the source code or an
high level language into intermediate code (machine level language). It is also
called translator in programming terminology. Interpreters executes each line of
statements slowly. This process is called Interpretation. For example Python is an
interpreted language, PHP, Ruby, and JavaScript.
Compiler vs interpreter
#include<iostream>
int main()
{
int a=10; output : 15
int b=5;
int c=a+b;
cout<<c;
return 0;
}
a=10 <<a=10
b=5 <<b=5
c=a+b <<c=15
print(c)
VARIABLES:
Python Variable is containers that store values. Python is not “statically typed”. We
do not need to declare variables before using them or declare their type. A variable is
created the moment we first assign a value to it. A Python variable is a name given to a
memory location.
RULES OF VARIABLES:
• A Python variable name must start with a letter or the underscore character.
• A Python variable name cannot start with a number.
• A Python variable name can only contain alpha-numeric characters and underscores (A-z,
0-9, and _ ).
• Variable in Python names are case-sensitive (name, Name, and NAME are three different
variables).
• The reserved words(keywords) in Python cannot be used to name the variable in Python.
Example 1 Example 2
a=20
b=30
c=40 output: 20
d=50 30
print(a) 40
print(b) 50
print(c)
print(d)
a=20
b=30
c=40 output: 20,30
d=50 40,50
print(a,b)
print(c,d)
EXAMPLE 3
age =20
salary =23.4 Output: 20, 23.4
name = “Abcd” Abcd
print(age,salary)
print(name)
EXAMPLE 4
a=b=c=10 EXAMPLE 5
print(a) Output: 10 a, b, c= 10,20,30 Output: 10
print(b) 10 print(a) 20
print(c) 10 print(b)
Data types:
• Numbers
• String
• Tuple
• List
• Set
• Dict
Number:
The numeric data type in Python represents the data that has a
numeric value. A numeric value can be an integer, a floating number, or even
a complex number. These values are defined as Python int, Python float,
and Python complex classes in Python.
• Integers – This value is represented by int class. It contains positive or
negative whole numbers (without fractions or decimals). In Python, there is
no limit to how long an integer value can be.
• Float – This value is represented by the float class. It is a real number with
a floating-point representation. It is specified by a decimal point.
Optionally, the character e or E followed by a positive or negative integer
may be appended to specify scientific notation.
• Complex Numbers – A complex number is represented by a complex class.
It is specified as (real part) + (imaginary part)j. For example – 2+3j
a = 5
print("Type of a: ", type(a))
b = 5.0
print("n Type of b: ", type(b))
c = 2 + 4j
print("n Type of c: ", type(c))
Output :
Type of a: <class 'int'>
Type of b: <class 'float'>
Type of c: <class 'complex'>
String:
Python are arrays of bytes representing Unicode characters. A string is a collection
of one or more characters put in a single quote, double-quote, or triple-quote. In Python
there is no character data type, a character is a string of length one. It is represented by str
class.
• Creating String
• Strings in Python can be created using single quotes, double quotes, or even triple
quotes.
• Example: This Python code showcases various string creation methods. It uses single
quotes, double quotes, and triple quotes to create strings with different content and
includes a multiline string. The code also demonstrates printing the strings and checking
their data types.
String1 = 'Welcome to the Geeks World'
print("String with the use of Single Quotes: ")
print(String1)
print('n’)
String1 = "I'm a Geek"
print("nString with the use of Double Quotes: ")
print(String1)
print(type(String1))
print('n’)
String1 = '''Geeks
For
Life'''
print("nCreating a multiline String: ")
print(String1)
Output:
String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str’>
Creating a multiline String:
Geeks
For
Life
LIST:
A group of comma separated values
enclosed in square bracket
Eg:- [10,20,30]
a= [5,5,5]
Print(type(a))
SET:
A group of comma separated value
enclosed with curly brackets.
Eg:- { 10,20,30}
a= {5,5,5}
print(type(a))
TUPLE:
A group of comma separated value
enclosed optionally in parenthesis.
Eg:- 10,20,30 or (10,20,30)
a= 5,5,5
print(type(a))
DICT:
A group of comma separated key-
value with enclosed curly brackets
Eg:- {“apple” : 10 , “ cat” : 20}
a={“ab” : 5 , “cd” : 5}
print(type(a))
Operators:
Operators are special symbols that perform operations on
variables and values. They are:
• Arithmetic operator
• Assignment operator
• Comparison (or) relational operator
• Logical operator
ARITHMETIC:-
OPERATOR OPEARATION EXAMPLE
1. + Addition 7+2 = 9
2. - Subtraction 7-2 = 5
3. * Multiplication 7*2 = 14
4. / Division 7/2 = 3.5
5. // Floor Division 7//2 = 3
6. % Modulo 7%2 = 1
7. ** Power 7**2 = 49
EXAMPLE:
a=7
b=2
print(a+b) Output: 9
print(a-b) 5
print(a*b) 14
print(a/b) 3.5
print(a//b) 3
print(a%b) 1
print(a**b) 49
Addition:-
a=int(input("enter values:"))
b=int(input("enter values:"))
print(a+b)
Subtraction:-
a=int(input("enter values:"))
b=int(input("enter values:"))
print(a-b)
Multiplication:-
a=int(input("enter values:"))
b=int(input("enter values:"))
print(a*b)
Division:-
a=int(input("enter values:"))
b=int(input("enter values:"))
print(a/b)
FloorDivision:-
a=int(input("enter values:"))
b=int(input("enter values:"))
print(a//b)
Power:-
a=int(input("enter values:"))
b=int(input("enter values:"))
print(a**b)
Modulo:-
a=int(input("enter values:"))
b=int(input("enter values:"))
print(a%b)
ASSIGNMENT:-
Operator Operation Example
= Assignment operator a=7
+= Addition Assign a+=1
( a=a+1)
-= Subtract Assign a-=1
*= Multiple Assign a*=1
/= Division Assign a/=1
%= Remainder Assign a%=1
**= Exponent Assign a**=2
Example:
Addition:-
a=5
b=2
a+=b
print(a)
(or)
a=int(input(“enter the values:”))
b=int(input(“enter the values:”))
a+=b
print(a)
Subtraction:-
a=5
b=2
a-=b
print(a)
(or)
a=int(input(“enter the values:”))
b=int(input(“enter the values:”))
a-=b
print(a)
Multiplication:-
a=5
b=2
a*=b
print(a)
(or)
a=int(input(“enter the values:”))
b=int(input(“enter the values:”))
a*=b
print(a)
Division:-
a=5
b=2
a/=b
print(a)
(or)
a=int(input(“enter the values:”))
b=int(input(“enter the values:”))
a/=b
print(a)
Remainder:-
a=5
b=2
a%=b
print(a)
(or)
a=int(input(“enter the values:”))
b=int(input(“enter the values:”))
a%=b
print(a)
Exponent:-
a=5
b=2
a**=b
print(a)
(or)
a=int(input(“enter the values:”))
b=int(input(“enter the values:”))
a**=b
print(a)
Comparison Operator:-
Operator Operation Example
== Is equal to 3==5
#false
!= Not equal to 3!=5
#true
> Greater than 3>5
#false
< lesser than 3<5
#true
>= greater or equal 3>=5
#false
<= lesser or equal 3<=5
#true
Example:-
Is equal to:-
a=5
b=2
print(a==b)
(or)
a=int(input(“enter the values:”))
b=int(input(“enter the values:”))
print(a==b)
Not equal to:-
a=5
b=2
print(a!=b)
(or)
a=int(input(“enter the values:”))
b=int(input(“enter the values:”))
print(a!=b)
Greater than:-
a=5
b=2
print(a>b)
(or)
a=int(input(“enter the values:”))
b=int(input(“enter the values:”))
print(a>b)
Lesser than:-
a=5
b=2
print(a<b)
(or)
a=int(input(“enter the values:”))
b=int(input(“enter the values:”))
print(a<b)
Greater than or equal to:-
a=5
b=2
print(a>=b)
(or)
a=int(input(“enter the values:”))
b=int(input(“enter the values:”))
print(a>=b)
Lesser than or equal to:-
a=5
b=2
print(a<=b)
(or)
a=int(input(“enter the values:”))
b=int(input(“enter the values:”))
print(a<=b)
Logical Operator:-
Logical operator are used to check whether an expression is
true or false. They are user in decision making.
Operator Operation Example
And a and b True: Only if both
. the operands are true
Or a or b True: if at least one of
. the operand is true
Not not a True: if the operand is
. false
a= int(input(“enter the value:”))
b=int(input(“enter the value:”))
(or)
a=4
b=3
print(a>b and a<b)
#false
print(a==b or a>=b)
#true
print(not a>b)
#false
EXPRESSION IN PYTHON:-
An expression is a combination of operators and operands that is
interpreted to produce some other values. In any programming
language, an expression is evaluated as per the precedence of its
operator. so that if there is more than one operator in an expression.
Their precedence decides which operation will be performed first. We
have many different type of expression in python. Lets discuss all types
along with some example:
1.CONSTANT EXP:-
There are the expressions that have constant values only.
Eg:- X = 15 + 1.3
print(X)
2.ARITHMETIC:-
An Arithmetic expression is a combination of numeric values,
operators, and sometimes parenthesis. The result of this type of
expression is also a numeric value. The operators used in this
expression are arithmetic operators like addition, subtraction, etc. here
are some arithmetic operators in python.
OPERATOR SYNTAX FUNCTIONING
+ X+Y ADDITION
- X-Y SUBTRACTION
* X*Y MULTIPLICATION
/ X/Y DIVISION
// X//Y QUOTIENT
% X%Y REMAINDER
** X**Y EXPONENTIATION
Example:-
x=40
y=12
add= x+y
sub=x-y
mul=x*y
div=x/y
print(add)
print(sub)
print(mul)
print(div)
3.ENTEGRAL EXP:-
These are the kind of expression that produce only integer result
after all computational and type conversion.
Eg:- a= 13
b= 12.0
c= a+ int(b)
print(c)
4.FLOATING EXP:-
These are the kind of exp which produce floating point number
as result after all computation and type conversions.
Eg:-
a=13
b=5
c= a/b
print(c)
5.RELATIONAL EXP:-
In these type of exp, arithmetic exp are written on both sides of
relational operator(>,<,>=,<=). Those arithmetic exp are evaluated first,
and then compared as per relational operator and produce a Boolean
output in the end. These exp are also called Boolean expression.
Eg:- a = 21
b = 13
c = 40
d = 37
x = (a+b) >= (d-c)
print(x)
6.LOGICAL EXP:-
These are kind of exp that result in true or false. It basically specifies one
or more conditions. For example (10 == 9) is a condition if 10 is equal to 9. As we
know it is not correct, so it will return false. Studying logical exp, we also come
across some logical operators which can be seen in logical exp most often, here
are some logical operations in python.
Operator Syntax Functioning
AND P and Q it return true if both P and Q
are true otherwise return false
OR P or Q it return true if at least one of
P and Q is true.
NOT not P if returns true, if condition P
is false.
Eg:-
P = (10 == 9)
Q = (7 > 5)
R = P and Q
S = P or Q
T = not P
print(R)
print(S)
print(T)
INPUT AND OUTPUT:-
How to use input method to get value from user?
Input is data entered by user in the program
In python input() function is available for input
SYNTAX:-
Variable=input(“No need to do type cast for string”)
Variable=int(input(“enter the number:”)) >>>enter the number:3
Variable=float(input(“enter value:”)) >>>enter value:2.4
Variable=bool(input(“enter:”)) >>>enter: True
Variable=complex(input(“enter value:”)) >>>enter value: 2+5j
OUTPUT:
Output can be displayed to the user using print statement.
SYNTAX:
print(expression/constant/variables)
print(“hello everyone”) >>>hello everyone
age=20
print(“My age is:”,age) >>>My age is:20
print(“hello”)
print(“nice to meet you”)
>>>hello
>>>nice to meet you
SEPARATE ARGUMENT:-
print(“hello” , ”everyone”, sep=‘**’)
>>>hello**everyone
END ARGUMENT:-
print(“hello”,”everyone”,sep=‘**’,end=‘ ‘)
print(“nice”, “to”, “meet”,”you”,sep=‘_’)
>>>hello**everyone nice_to_meet_you
a=5
b=8
print(a,b,sep=‘@’)
>>>5@8
FORMATTED STRING:-
• .format()
• f string
print(“{} {} everyone”.format(‘hi’,’how are you?’))
>>>hi how are you everyone
x=“Apple”
y=“Orange”
print(“{},{}”.format(x,y))
>>>Apple,Orange
print(f”{x},{y}”)
>>>Apple,Orange
Conditional statement:-
Selective:-
• if condition
• if else
• elif condition
• Nested if
if condition:-
In computer programming, the if statement is a conditional
statement. It is used to execute a block of code only when a
specific condition is met
number = 10
if number > 0:
print('Number is positive’)
print('This statement always executes')
if else:-
An if statement can have an optional else clause. The else statement
executes if the condition in the if statement evaluates to False
number = 10
if number > 0:
print('Positive number’)
else:
print('Negative number’)
print('This statement always executes’)
if elif else statement:-
The if...else statement is used to execute a block of code among two
alternatives.
However, if we need to make a choice between more than two alternatives,
we use the if...elif...else statement
.
Example for if elif else:-
number = 0
if number > 0:
print('Positive number’)
elif number <0:
print('Negative number’)
else:
print('Zero’)
print('This statement is always executed')
Nested if:-
It is possible to include an if statement inside another if statement
For example:-
number = 5
if number >= 0:
if number == 0:
print('Number is 0’)
else:
print('Number is positive’)
else:
print('Number is negative')
for loop:-
In Python programming, we use for loops to repeat some code a certain number of times. It
allows us to execute a statement or a group of statements multiple times by reducing the burden of
writing several lines of code.
Example:-
LOOP TO ITERATE THROUGH DICTIONARY:-
programmingLanguages = {'J':'Java','P':'Python'}
for key,value in programmingLanguages.items():
print(key,value)
LOOP USING ZIP() FOR PARALLEL ITERATION:-
a1 = ['Python','Java','CSharp']
b2 = [1,2,3]
for i,j in zip(a1,b2):
print(i,j)
NESTED LOOP IN PYTHON:-
list1 = [5,10,15,20]
list2 = ['Tomatoes','Potatoes','Carrots','Cucumbers']
for x in list1:
for y in list2:
print(x,y)
BREAK:-
vehicles = ['Car','Cycle','Bus','Tempo']
for v in vehicles:
if v == "Bus":
break
print(v)
CONTINUE:-
vehicles = ['Car','Cycle','Bus','Tempo']
for v in vehicles:
if v == "Bus":
continue
print(v)
COUNT THE NUMBER:-
numbers = [12,3,56,67,89,90]
count = 0
for n in numbers:
count += 1
print(count)
SUM OF ALL NUMBER:-
numbers = [12,3,56,67,89,90]
sum = 0
for n in numbers:
sum += n
print(sum)
TRIANGLE LOOP:-
for i in range(1,5):
for j in range(i):
print('*',end='')
print()
MAXIMUM NUMBER:-
numbers = [1,4,50,80,12]
max = 0
for n in numbers:
if(n>max):
max = n
print(max)
SORT THE NUMBER IN DECENDING ORDER:-
numbers = [1,4,50,80,12]
for i in range(0, len(numbers)):
for j in range(i+1, len(numbers)):
if(numbers[i] < numbers[j]):
temp = numbers[i]
numbers[i] = numbers[j];
numbers[j] = temp
print(numbers)
MULTIPLE OF 3 USING RANGE FUNCTION():-
for i in range(3,20,3):
print(i)
REVERSE ORDER:-
for i in range(10,0,-1):
print(i)
while loop:-
With the while loop we can execute a set of statements as long as a
condition is true.
Example:-
Print i as long as i is less than 6:
i = 1
while i < 6:
print(i)
i += 1
Break:-
Exit the loop when i is 3:
i = 1
while i < 6:
print(i)
if i == 3:
break
i += 1
Continue:-
Continue to the next iteration if i is 3:
i = 0
while i < 6:
i += 1
if i == 3:
continue
print(i)
else statement:-
Print a message once the condition is false:
i = 1
while i < 6:
print(i)
i += 1
else:
print("i is no longer less than 6")

More Related Content

Similar to MODULE. .pptx

basics of python programming5.pdf
basics of python programming5.pdfbasics of python programming5.pdf
basics of python programming5.pdfPushkaran3
 
Python Training in Bangalore | Python Introduction Session | Learnbay
Python Training in Bangalore |  Python Introduction Session | LearnbayPython Training in Bangalore |  Python Introduction Session | Learnbay
Python Training in Bangalore | Python Introduction Session | LearnbayLearnbayin
 
python-online&offline-training-in-kphb-hyderabad (1) (1).pdf
python-online&offline-training-in-kphb-hyderabad (1) (1).pdfpython-online&offline-training-in-kphb-hyderabad (1) (1).pdf
python-online&offline-training-in-kphb-hyderabad (1) (1).pdfKosmikTech1
 
C_Programming_Language_tutorial__Autosaved_.pptx
C_Programming_Language_tutorial__Autosaved_.pptxC_Programming_Language_tutorial__Autosaved_.pptx
C_Programming_Language_tutorial__Autosaved_.pptxLikhil181
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C ProgrammingMOHAMAD NOH AHMAD
 
Unit 4 Foc
Unit 4 FocUnit 4 Foc
Unit 4 FocJAYA
 
Python programming workshop session 1
Python programming workshop session 1Python programming workshop session 1
Python programming workshop session 1Abdul Haseeb
 
basics of C and c++ by eteaching
basics of C and c++ by eteachingbasics of C and c++ by eteaching
basics of C and c++ by eteachingeteaching
 
modul-python-all.pptx
modul-python-all.pptxmodul-python-all.pptx
modul-python-all.pptxYusuf Ayuba
 
Python programming workshop
Python programming workshopPython programming workshop
Python programming workshopBAINIDA
 
Python Basics by Akanksha Bali
Python Basics by Akanksha BaliPython Basics by Akanksha Bali
Python Basics by Akanksha BaliAkanksha Bali
 
Introduction to Python Programming | InsideAIML
Introduction to Python Programming | InsideAIMLIntroduction to Python Programming | InsideAIML
Introduction to Python Programming | InsideAIMLVijaySharma802
 

Similar to MODULE. .pptx (20)

chapter_5_ppt_em_220247.pptx
chapter_5_ppt_em_220247.pptxchapter_5_ppt_em_220247.pptx
chapter_5_ppt_em_220247.pptx
 
Python Basics
Python BasicsPython Basics
Python Basics
 
Python Scipy Numpy
Python Scipy NumpyPython Scipy Numpy
Python Scipy Numpy
 
Python
PythonPython
Python
 
basics of python programming5.pdf
basics of python programming5.pdfbasics of python programming5.pdf
basics of python programming5.pdf
 
Python.pptx
Python.pptxPython.pptx
Python.pptx
 
Python basics
Python basicsPython basics
Python basics
 
Python Training in Bangalore | Python Introduction Session | Learnbay
Python Training in Bangalore |  Python Introduction Session | LearnbayPython Training in Bangalore |  Python Introduction Session | Learnbay
Python Training in Bangalore | Python Introduction Session | Learnbay
 
python-online&offline-training-in-kphb-hyderabad (1) (1).pdf
python-online&offline-training-in-kphb-hyderabad (1) (1).pdfpython-online&offline-training-in-kphb-hyderabad (1) (1).pdf
python-online&offline-training-in-kphb-hyderabad (1) (1).pdf
 
Python programming
Python  programmingPython  programming
Python programming
 
C_Programming_Language_tutorial__Autosaved_.pptx
C_Programming_Language_tutorial__Autosaved_.pptxC_Programming_Language_tutorial__Autosaved_.pptx
C_Programming_Language_tutorial__Autosaved_.pptx
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
 
Unit 4 Foc
Unit 4 FocUnit 4 Foc
Unit 4 Foc
 
Python programming workshop session 1
Python programming workshop session 1Python programming workshop session 1
Python programming workshop session 1
 
basics of C and c++ by eteaching
basics of C and c++ by eteachingbasics of C and c++ by eteaching
basics of C and c++ by eteaching
 
modul-python-all.pptx
modul-python-all.pptxmodul-python-all.pptx
modul-python-all.pptx
 
Python programming workshop
Python programming workshopPython programming workshop
Python programming workshop
 
Python Basics by Akanksha Bali
Python Basics by Akanksha BaliPython Basics by Akanksha Bali
Python Basics by Akanksha Bali
 
Python-Cheat-Sheet.pdf
Python-Cheat-Sheet.pdfPython-Cheat-Sheet.pdf
Python-Cheat-Sheet.pdf
 
Introduction to Python Programming | InsideAIML
Introduction to Python Programming | InsideAIMLIntroduction to Python Programming | InsideAIML
Introduction to Python Programming | InsideAIML
 

Recently uploaded

(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxhumanexperienceaaa
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingrknatarajan
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 

Recently uploaded (20)

(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 

MODULE. .pptx

  • 1. MODULE : 1 Data types, Operator and expression, input and output statements. Control structure – selective and Repetitive structure
  • 2. What is Python It is a high level programming language and interpreted program language, we can execute the programs with less line of codes. Syntax : print(“hello world”)  hello world What is interpreter? • Interpreters are the computer program that will convert the source code or an high level language into intermediate code (machine level language). It is also called translator in programming terminology. Interpreters executes each line of statements slowly. This process is called Interpretation. For example Python is an interpreted language, PHP, Ruby, and JavaScript.
  • 3. Compiler vs interpreter #include<iostream> int main() { int a=10; output : 15 int b=5; int c=a+b; cout<<c; return 0; } a=10 <<a=10 b=5 <<b=5 c=a+b <<c=15 print(c)
  • 4. VARIABLES: Python Variable is containers that store values. Python is not “statically typed”. We do not need to declare variables before using them or declare their type. A variable is created the moment we first assign a value to it. A Python variable is a name given to a memory location. RULES OF VARIABLES: • A Python variable name must start with a letter or the underscore character. • A Python variable name cannot start with a number. • A Python variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ ). • Variable in Python names are case-sensitive (name, Name, and NAME are three different variables). • The reserved words(keywords) in Python cannot be used to name the variable in Python.
  • 5. Example 1 Example 2 a=20 b=30 c=40 output: 20 d=50 30 print(a) 40 print(b) 50 print(c) print(d) a=20 b=30 c=40 output: 20,30 d=50 40,50 print(a,b) print(c,d)
  • 6. EXAMPLE 3 age =20 salary =23.4 Output: 20, 23.4 name = “Abcd” Abcd print(age,salary) print(name) EXAMPLE 4 a=b=c=10 EXAMPLE 5 print(a) Output: 10 a, b, c= 10,20,30 Output: 10 print(b) 10 print(a) 20 print(c) 10 print(b)
  • 7. Data types: • Numbers • String • Tuple • List • Set • Dict
  • 8. Number: The numeric data type in Python represents the data that has a numeric value. A numeric value can be an integer, a floating number, or even a complex number. These values are defined as Python int, Python float, and Python complex classes in Python. • Integers – This value is represented by int class. It contains positive or negative whole numbers (without fractions or decimals). In Python, there is no limit to how long an integer value can be. • Float – This value is represented by the float class. It is a real number with a floating-point representation. It is specified by a decimal point. Optionally, the character e or E followed by a positive or negative integer may be appended to specify scientific notation. • Complex Numbers – A complex number is represented by a complex class. It is specified as (real part) + (imaginary part)j. For example – 2+3j
  • 9. a = 5 print("Type of a: ", type(a)) b = 5.0 print("n Type of b: ", type(b)) c = 2 + 4j print("n Type of c: ", type(c)) Output : Type of a: <class 'int'> Type of b: <class 'float'> Type of c: <class 'complex'>
  • 10. String: Python are arrays of bytes representing Unicode characters. A string is a collection of one or more characters put in a single quote, double-quote, or triple-quote. In Python there is no character data type, a character is a string of length one. It is represented by str class. • Creating String • Strings in Python can be created using single quotes, double quotes, or even triple quotes. • Example: This Python code showcases various string creation methods. It uses single quotes, double quotes, and triple quotes to create strings with different content and includes a multiline string. The code also demonstrates printing the strings and checking their data types.
  • 11. String1 = 'Welcome to the Geeks World' print("String with the use of Single Quotes: ") print(String1) print('n’) String1 = "I'm a Geek" print("nString with the use of Double Quotes: ") print(String1) print(type(String1)) print('n’) String1 = '''Geeks For Life''' print("nCreating a multiline String: ") print(String1)
  • 12. Output: String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek <class 'str’> Creating a multiline String: Geeks For Life
  • 13. LIST: A group of comma separated values enclosed in square bracket Eg:- [10,20,30] a= [5,5,5] Print(type(a)) SET: A group of comma separated value enclosed with curly brackets. Eg:- { 10,20,30} a= {5,5,5} print(type(a)) TUPLE: A group of comma separated value enclosed optionally in parenthesis. Eg:- 10,20,30 or (10,20,30) a= 5,5,5 print(type(a)) DICT: A group of comma separated key- value with enclosed curly brackets Eg:- {“apple” : 10 , “ cat” : 20} a={“ab” : 5 , “cd” : 5} print(type(a))
  • 14. Operators: Operators are special symbols that perform operations on variables and values. They are: • Arithmetic operator • Assignment operator • Comparison (or) relational operator • Logical operator
  • 15. ARITHMETIC:- OPERATOR OPEARATION EXAMPLE 1. + Addition 7+2 = 9 2. - Subtraction 7-2 = 5 3. * Multiplication 7*2 = 14 4. / Division 7/2 = 3.5 5. // Floor Division 7//2 = 3 6. % Modulo 7%2 = 1 7. ** Power 7**2 = 49
  • 16. EXAMPLE: a=7 b=2 print(a+b) Output: 9 print(a-b) 5 print(a*b) 14 print(a/b) 3.5 print(a//b) 3 print(a%b) 1 print(a**b) 49
  • 17. Addition:- a=int(input("enter values:")) b=int(input("enter values:")) print(a+b) Subtraction:- a=int(input("enter values:")) b=int(input("enter values:")) print(a-b) Multiplication:- a=int(input("enter values:")) b=int(input("enter values:")) print(a*b)
  • 18. Division:- a=int(input("enter values:")) b=int(input("enter values:")) print(a/b) FloorDivision:- a=int(input("enter values:")) b=int(input("enter values:")) print(a//b) Power:- a=int(input("enter values:")) b=int(input("enter values:")) print(a**b)
  • 20. ASSIGNMENT:- Operator Operation Example = Assignment operator a=7 += Addition Assign a+=1 ( a=a+1) -= Subtract Assign a-=1 *= Multiple Assign a*=1 /= Division Assign a/=1 %= Remainder Assign a%=1 **= Exponent Assign a**=2
  • 27. Comparison Operator:- Operator Operation Example == Is equal to 3==5 #false != Not equal to 3!=5 #true > Greater than 3>5 #false < lesser than 3<5 #true >= greater or equal 3>=5 #false <= lesser or equal 3<=5 #true
  • 28. Example:- Is equal to:- a=5 b=2 print(a==b) (or) a=int(input(“enter the values:”)) b=int(input(“enter the values:”)) print(a==b)
  • 29. Not equal to:- a=5 b=2 print(a!=b) (or) a=int(input(“enter the values:”)) b=int(input(“enter the values:”)) print(a!=b)
  • 30. Greater than:- a=5 b=2 print(a>b) (or) a=int(input(“enter the values:”)) b=int(input(“enter the values:”)) print(a>b)
  • 31. Lesser than:- a=5 b=2 print(a<b) (or) a=int(input(“enter the values:”)) b=int(input(“enter the values:”)) print(a<b)
  • 32. Greater than or equal to:- a=5 b=2 print(a>=b) (or) a=int(input(“enter the values:”)) b=int(input(“enter the values:”)) print(a>=b)
  • 33. Lesser than or equal to:- a=5 b=2 print(a<=b) (or) a=int(input(“enter the values:”)) b=int(input(“enter the values:”)) print(a<=b)
  • 34. Logical Operator:- Logical operator are used to check whether an expression is true or false. They are user in decision making. Operator Operation Example And a and b True: Only if both . the operands are true Or a or b True: if at least one of . the operand is true Not not a True: if the operand is . false
  • 35. a= int(input(“enter the value:”)) b=int(input(“enter the value:”)) (or) a=4 b=3 print(a>b and a<b) #false print(a==b or a>=b) #true print(not a>b) #false
  • 36. EXPRESSION IN PYTHON:- An expression is a combination of operators and operands that is interpreted to produce some other values. In any programming language, an expression is evaluated as per the precedence of its operator. so that if there is more than one operator in an expression. Their precedence decides which operation will be performed first. We have many different type of expression in python. Lets discuss all types along with some example: 1.CONSTANT EXP:- There are the expressions that have constant values only. Eg:- X = 15 + 1.3 print(X)
  • 37. 2.ARITHMETIC:- An Arithmetic expression is a combination of numeric values, operators, and sometimes parenthesis. The result of this type of expression is also a numeric value. The operators used in this expression are arithmetic operators like addition, subtraction, etc. here are some arithmetic operators in python. OPERATOR SYNTAX FUNCTIONING + X+Y ADDITION - X-Y SUBTRACTION * X*Y MULTIPLICATION / X/Y DIVISION // X//Y QUOTIENT % X%Y REMAINDER ** X**Y EXPONENTIATION
  • 39. 3.ENTEGRAL EXP:- These are the kind of expression that produce only integer result after all computational and type conversion. Eg:- a= 13 b= 12.0 c= a+ int(b) print(c) 4.FLOATING EXP:- These are the kind of exp which produce floating point number as result after all computation and type conversions. Eg:- a=13 b=5 c= a/b print(c)
  • 40. 5.RELATIONAL EXP:- In these type of exp, arithmetic exp are written on both sides of relational operator(>,<,>=,<=). Those arithmetic exp are evaluated first, and then compared as per relational operator and produce a Boolean output in the end. These exp are also called Boolean expression. Eg:- a = 21 b = 13 c = 40 d = 37 x = (a+b) >= (d-c) print(x)
  • 41. 6.LOGICAL EXP:- These are kind of exp that result in true or false. It basically specifies one or more conditions. For example (10 == 9) is a condition if 10 is equal to 9. As we know it is not correct, so it will return false. Studying logical exp, we also come across some logical operators which can be seen in logical exp most often, here are some logical operations in python. Operator Syntax Functioning AND P and Q it return true if both P and Q are true otherwise return false OR P or Q it return true if at least one of P and Q is true. NOT not P if returns true, if condition P is false.
  • 42. Eg:- P = (10 == 9) Q = (7 > 5) R = P and Q S = P or Q T = not P print(R) print(S) print(T)
  • 43. INPUT AND OUTPUT:- How to use input method to get value from user? Input is data entered by user in the program In python input() function is available for input SYNTAX:- Variable=input(“No need to do type cast for string”) Variable=int(input(“enter the number:”)) >>>enter the number:3 Variable=float(input(“enter value:”)) >>>enter value:2.4 Variable=bool(input(“enter:”)) >>>enter: True Variable=complex(input(“enter value:”)) >>>enter value: 2+5j
  • 44. OUTPUT: Output can be displayed to the user using print statement. SYNTAX: print(expression/constant/variables) print(“hello everyone”) >>>hello everyone age=20 print(“My age is:”,age) >>>My age is:20 print(“hello”) print(“nice to meet you”) >>>hello >>>nice to meet you
  • 45. SEPARATE ARGUMENT:- print(“hello” , ”everyone”, sep=‘**’) >>>hello**everyone END ARGUMENT:- print(“hello”,”everyone”,sep=‘**’,end=‘ ‘) print(“nice”, “to”, “meet”,”you”,sep=‘_’) >>>hello**everyone nice_to_meet_you a=5 b=8 print(a,b,sep=‘@’) >>>5@8
  • 46. FORMATTED STRING:- • .format() • f string print(“{} {} everyone”.format(‘hi’,’how are you?’)) >>>hi how are you everyone x=“Apple” y=“Orange” print(“{},{}”.format(x,y)) >>>Apple,Orange print(f”{x},{y}”) >>>Apple,Orange
  • 47. Conditional statement:- Selective:- • if condition • if else • elif condition • Nested if if condition:- In computer programming, the if statement is a conditional statement. It is used to execute a block of code only when a specific condition is met number = 10 if number > 0: print('Number is positive’) print('This statement always executes')
  • 48. if else:- An if statement can have an optional else clause. The else statement executes if the condition in the if statement evaluates to False number = 10 if number > 0: print('Positive number’) else: print('Negative number’) print('This statement always executes’) if elif else statement:- The if...else statement is used to execute a block of code among two alternatives. However, if we need to make a choice between more than two alternatives, we use the if...elif...else statement .
  • 49. Example for if elif else:- number = 0 if number > 0: print('Positive number’) elif number <0: print('Negative number’) else: print('Zero’) print('This statement is always executed')
  • 50. Nested if:- It is possible to include an if statement inside another if statement For example:- number = 5 if number >= 0: if number == 0: print('Number is 0’) else: print('Number is positive’) else: print('Number is negative')
  • 51. for loop:- In Python programming, we use for loops to repeat some code a certain number of times. It allows us to execute a statement or a group of statements multiple times by reducing the burden of writing several lines of code. Example:- LOOP TO ITERATE THROUGH DICTIONARY:- programmingLanguages = {'J':'Java','P':'Python'} for key,value in programmingLanguages.items(): print(key,value) LOOP USING ZIP() FOR PARALLEL ITERATION:- a1 = ['Python','Java','CSharp'] b2 = [1,2,3] for i,j in zip(a1,b2): print(i,j)
  • 52. NESTED LOOP IN PYTHON:- list1 = [5,10,15,20] list2 = ['Tomatoes','Potatoes','Carrots','Cucumbers'] for x in list1: for y in list2: print(x,y) BREAK:- vehicles = ['Car','Cycle','Bus','Tempo'] for v in vehicles: if v == "Bus": break print(v)
  • 53. CONTINUE:- vehicles = ['Car','Cycle','Bus','Tempo'] for v in vehicles: if v == "Bus": continue print(v) COUNT THE NUMBER:- numbers = [12,3,56,67,89,90] count = 0 for n in numbers: count += 1 print(count)
  • 54. SUM OF ALL NUMBER:- numbers = [12,3,56,67,89,90] sum = 0 for n in numbers: sum += n print(sum) TRIANGLE LOOP:- for i in range(1,5): for j in range(i): print('*',end='') print()
  • 55. MAXIMUM NUMBER:- numbers = [1,4,50,80,12] max = 0 for n in numbers: if(n>max): max = n print(max) SORT THE NUMBER IN DECENDING ORDER:- numbers = [1,4,50,80,12] for i in range(0, len(numbers)): for j in range(i+1, len(numbers)): if(numbers[i] < numbers[j]): temp = numbers[i] numbers[i] = numbers[j]; numbers[j] = temp print(numbers)
  • 56. MULTIPLE OF 3 USING RANGE FUNCTION():- for i in range(3,20,3): print(i) REVERSE ORDER:- for i in range(10,0,-1): print(i)
  • 57. while loop:- With the while loop we can execute a set of statements as long as a condition is true. Example:- Print i as long as i is less than 6: i = 1 while i < 6: print(i) i += 1 Break:- Exit the loop when i is 3: i = 1 while i < 6: print(i) if i == 3: break i += 1
  • 58. Continue:- Continue to the next iteration if i is 3: i = 0 while i < 6: i += 1 if i == 3: continue print(i) else statement:- Print a message once the condition is false: i = 1 while i < 6: print(i) i += 1 else: print("i is no longer less than 6")