尊敬的 微信汇率:1円 ≈ 0.046078 元 支付宝汇率:1円 ≈ 0.046168元 [退出登录]
SlideShare a Scribd company logo
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

chapter_5_ppt_em_220247.pptx
chapter_5_ppt_em_220247.pptxchapter_5_ppt_em_220247.pptx
chapter_5_ppt_em_220247.pptx
RAJAMURUGANAMECAPCSE
 
Python Basics
Python BasicsPython Basics
Python Basics
tusharpanda88
 
Python Scipy Numpy
Python Scipy NumpyPython Scipy Numpy
Python Scipy Numpy
Girish Khanzode
 
Python
PythonPython
basics of python programming5.pdf
basics of python programming5.pdfbasics of python programming5.pdf
basics of python programming5.pdf
Pushkaran3
 
Python.pptx
Python.pptxPython.pptx
Python.pptx
EliasPetros
 
Python basics
Python basicsPython basics
Python basics
RANAALIMAJEEDRAJPUT
 
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
Learnbayin
 
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
KosmikTech1
 
Python programming
Python  programmingPython  programming
Python programming
Ashwin Kumar Ramasamy
 
C_Programming_Language_tutorial__Autosaved_.pptx
C_Programming_Language_tutorial__Autosaved_.pptxC_Programming_Language_tutorial__Autosaved_.pptx
C_Programming_Language_tutorial__Autosaved_.pptx
Likhil181
 
Unit 4 Foc
Unit 4 FocUnit 4 Foc
Unit 4 Foc
JAYA
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
MOHAMAD NOH AHMAD
 
Python programming workshop session 1
Python programming workshop session 1Python programming workshop session 1
Python programming workshop session 1
Abdul 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 eteaching
eteaching
 
modul-python-all.pptx
modul-python-all.pptxmodul-python-all.pptx
modul-python-all.pptx
Yusuf Ayuba
 
python notes for MASTER OF COMPUTER APPLIICATION_ppt.pptx
python notes for MASTER OF COMPUTER APPLIICATION_ppt.pptxpython notes for MASTER OF COMPUTER APPLIICATION_ppt.pptx
python notes for MASTER OF COMPUTER APPLIICATION_ppt.pptx
yuvarajkumar334
 
Python programming workshop
Python programming workshopPython programming workshop
Python programming workshop
BAINIDA
 
1691912901477_Python_Basics and list,tuple,string.pptx
1691912901477_Python_Basics and list,tuple,string.pptx1691912901477_Python_Basics and list,tuple,string.pptx
1691912901477_Python_Basics and list,tuple,string.pptx
KUSHSHARMA630049
 
Python Basics by Akanksha Bali
Python Basics by Akanksha BaliPython Basics by Akanksha Bali
Python Basics by Akanksha Bali
Akanksha Bali
 

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
 
Unit 4 Foc
Unit 4 FocUnit 4 Foc
Unit 4 Foc
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
 
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 notes for MASTER OF COMPUTER APPLIICATION_ppt.pptx
python notes for MASTER OF COMPUTER APPLIICATION_ppt.pptxpython notes for MASTER OF COMPUTER APPLIICATION_ppt.pptx
python notes for MASTER OF COMPUTER APPLIICATION_ppt.pptx
 
Python programming workshop
Python programming workshopPython programming workshop
Python programming workshop
 
1691912901477_Python_Basics and list,tuple,string.pptx
1691912901477_Python_Basics and list,tuple,string.pptx1691912901477_Python_Basics and list,tuple,string.pptx
1691912901477_Python_Basics and list,tuple,string.pptx
 
Python Basics by Akanksha Bali
Python Basics by Akanksha BaliPython Basics by Akanksha Bali
Python Basics by Akanksha Bali
 

Recently uploaded

Call Girls In Lucknow 🔥 +91-7014168258🔥High Profile Call Girl Lucknow
Call Girls In Lucknow 🔥 +91-7014168258🔥High Profile Call Girl LucknowCall Girls In Lucknow 🔥 +91-7014168258🔥High Profile Call Girl Lucknow
Call Girls In Lucknow 🔥 +91-7014168258🔥High Profile Call Girl Lucknow
yogita singh$A17
 
一比一原版(psu学位证书)美国匹兹堡州立大学毕业证如何办理
一比一原版(psu学位证书)美国匹兹堡州立大学毕业证如何办理一比一原版(psu学位证书)美国匹兹堡州立大学毕业证如何办理
一比一原版(psu学位证书)美国匹兹堡州立大学毕业证如何办理
nonods
 
TENDERS and Contracts basic syllabus for engineering
TENDERS and Contracts basic syllabus for engineeringTENDERS and Contracts basic syllabus for engineering
TENDERS and Contracts basic syllabus for engineering
SnehalChavan75
 
🔥Young College Call Girls Chandigarh 💯Call Us 🔝 7737669865 🔝💃Independent Chan...
🔥Young College Call Girls Chandigarh 💯Call Us 🔝 7737669865 🔝💃Independent Chan...🔥Young College Call Girls Chandigarh 💯Call Us 🔝 7737669865 🔝💃Independent Chan...
🔥Young College Call Girls Chandigarh 💯Call Us 🔝 7737669865 🔝💃Independent Chan...
sonamrawat5631
 
Data Communication and Computer Networks Management System Project Report.pdf
Data Communication and Computer Networks Management System Project Report.pdfData Communication and Computer Networks Management System Project Report.pdf
Data Communication and Computer Networks Management System Project Report.pdf
Kamal Acharya
 
An In-Depth Exploration of Natural Language Processing: Evolution, Applicatio...
An In-Depth Exploration of Natural Language Processing: Evolution, Applicatio...An In-Depth Exploration of Natural Language Processing: Evolution, Applicatio...
An In-Depth Exploration of Natural Language Processing: Evolution, Applicatio...
DharmaBanothu
 
Update 40 models( Solar Cell ) in SPICE PARK(JUL2024)
Update 40 models( Solar Cell ) in SPICE PARK(JUL2024)Update 40 models( Solar Cell ) in SPICE PARK(JUL2024)
Update 40 models( Solar Cell ) in SPICE PARK(JUL2024)
Tsuyoshi Horigome
 
anatomy of space vehicle and aerospace structures.pptx
anatomy of space vehicle and aerospace structures.pptxanatomy of space vehicle and aerospace structures.pptx
anatomy of space vehicle and aerospace structures.pptx
ssusercf1619
 
My Aerospace Design and Structures Career Engineering LinkedIn version Presen...
My Aerospace Design and Structures Career Engineering LinkedIn version Presen...My Aerospace Design and Structures Career Engineering LinkedIn version Presen...
My Aerospace Design and Structures Career Engineering LinkedIn version Presen...
Geoffrey Wardle. MSc. MSc. Snr.MAIAA
 
💋Mature Women / Aunty Call Girls Gurgaon 💯Call Us 🔝 9999965857 🔝💃Independent ...
💋Mature Women / Aunty Call Girls Gurgaon 💯Call Us 🔝 9999965857 🔝💃Independent ...💋Mature Women / Aunty Call Girls Gurgaon 💯Call Us 🔝 9999965857 🔝💃Independent ...
💋Mature Women / Aunty Call Girls Gurgaon 💯Call Us 🔝 9999965857 🔝💃Independent ...
rupa singh
 
Covid Management System Project Report.pdf
Covid Management System Project Report.pdfCovid Management System Project Report.pdf
Covid Management System Project Report.pdf
Kamal Acharya
 
My Airframe Metallic Design Capability Studies..pdf
My Airframe Metallic Design Capability Studies..pdfMy Airframe Metallic Design Capability Studies..pdf
My Airframe Metallic Design Capability Studies..pdf
Geoffrey Wardle. MSc. MSc. Snr.MAIAA
 
Sri Guru Hargobind Ji - Bandi Chor Guru.pdf
Sri Guru Hargobind Ji - Bandi Chor Guru.pdfSri Guru Hargobind Ji - Bandi Chor Guru.pdf
Sri Guru Hargobind Ji - Bandi Chor Guru.pdf
Balvir Singh
 
❣Unsatisfied Bhabhi Call Girls Surat 💯Call Us 🔝 7014168258 🔝💃Independent Sura...
❣Unsatisfied Bhabhi Call Girls Surat 💯Call Us 🔝 7014168258 🔝💃Independent Sura...❣Unsatisfied Bhabhi Call Girls Surat 💯Call Us 🔝 7014168258 🔝💃Independent Sura...
❣Unsatisfied Bhabhi Call Girls Surat 💯Call Us 🔝 7014168258 🔝💃Independent Sura...
hotchicksescort
 
The Differences between Schedule 40 PVC Conduit Pipe and Schedule 80 PVC Conduit
The Differences between Schedule 40 PVC Conduit Pipe and Schedule 80 PVC ConduitThe Differences between Schedule 40 PVC Conduit Pipe and Schedule 80 PVC Conduit
The Differences between Schedule 40 PVC Conduit Pipe and Schedule 80 PVC Conduit
Guangdong Ctube Industry Co., Ltd.
 
❣Independent Call Girls Chennai 💯Call Us 🔝 7737669865 🔝💃Independent Chennai E...
❣Independent Call Girls Chennai 💯Call Us 🔝 7737669865 🔝💃Independent Chennai E...❣Independent Call Girls Chennai 💯Call Us 🔝 7737669865 🔝💃Independent Chennai E...
❣Independent Call Girls Chennai 💯Call Us 🔝 7737669865 🔝💃Independent Chennai E...
nainakaoornoida
 
Basic principle and types Static Relays ppt
Basic principle and  types  Static Relays pptBasic principle and  types  Static Relays ppt
Basic principle and types Static Relays ppt
Sri Ramakrishna Institute of Technology
 
🔥Independent Call Girls In Pune 💯Call Us 🔝 7014168258 🔝💃Independent Pune Esco...
🔥Independent Call Girls In Pune 💯Call Us 🔝 7014168258 🔝💃Independent Pune Esco...🔥Independent Call Girls In Pune 💯Call Us 🔝 7014168258 🔝💃Independent Pune Esco...
🔥Independent Call Girls In Pune 💯Call Us 🔝 7014168258 🔝💃Independent Pune Esco...
AK47
 
ESCORT SERVICE FULL ENJOY - @9711199012, Mayur Vihar CALL GIRLS SERVICE Delhi
ESCORT SERVICE FULL ENJOY - @9711199012, Mayur Vihar CALL GIRLS SERVICE DelhiESCORT SERVICE FULL ENJOY - @9711199012, Mayur Vihar CALL GIRLS SERVICE Delhi
ESCORT SERVICE FULL ENJOY - @9711199012, Mayur Vihar CALL GIRLS SERVICE Delhi
AK47
 
🚺ANJALI MEHTA High Profile Call Girls Ahmedabad 💯Call Us 🔝 9352988975 🔝💃Top C...
🚺ANJALI MEHTA High Profile Call Girls Ahmedabad 💯Call Us 🔝 9352988975 🔝💃Top C...🚺ANJALI MEHTA High Profile Call Girls Ahmedabad 💯Call Us 🔝 9352988975 🔝💃Top C...
🚺ANJALI MEHTA High Profile Call Girls Ahmedabad 💯Call Us 🔝 9352988975 🔝💃Top C...
dulbh kashyap
 

Recently uploaded (20)

Call Girls In Lucknow 🔥 +91-7014168258🔥High Profile Call Girl Lucknow
Call Girls In Lucknow 🔥 +91-7014168258🔥High Profile Call Girl LucknowCall Girls In Lucknow 🔥 +91-7014168258🔥High Profile Call Girl Lucknow
Call Girls In Lucknow 🔥 +91-7014168258🔥High Profile Call Girl Lucknow
 
一比一原版(psu学位证书)美国匹兹堡州立大学毕业证如何办理
一比一原版(psu学位证书)美国匹兹堡州立大学毕业证如何办理一比一原版(psu学位证书)美国匹兹堡州立大学毕业证如何办理
一比一原版(psu学位证书)美国匹兹堡州立大学毕业证如何办理
 
TENDERS and Contracts basic syllabus for engineering
TENDERS and Contracts basic syllabus for engineeringTENDERS and Contracts basic syllabus for engineering
TENDERS and Contracts basic syllabus for engineering
 
🔥Young College Call Girls Chandigarh 💯Call Us 🔝 7737669865 🔝💃Independent Chan...
🔥Young College Call Girls Chandigarh 💯Call Us 🔝 7737669865 🔝💃Independent Chan...🔥Young College Call Girls Chandigarh 💯Call Us 🔝 7737669865 🔝💃Independent Chan...
🔥Young College Call Girls Chandigarh 💯Call Us 🔝 7737669865 🔝💃Independent Chan...
 
Data Communication and Computer Networks Management System Project Report.pdf
Data Communication and Computer Networks Management System Project Report.pdfData Communication and Computer Networks Management System Project Report.pdf
Data Communication and Computer Networks Management System Project Report.pdf
 
An In-Depth Exploration of Natural Language Processing: Evolution, Applicatio...
An In-Depth Exploration of Natural Language Processing: Evolution, Applicatio...An In-Depth Exploration of Natural Language Processing: Evolution, Applicatio...
An In-Depth Exploration of Natural Language Processing: Evolution, Applicatio...
 
Update 40 models( Solar Cell ) in SPICE PARK(JUL2024)
Update 40 models( Solar Cell ) in SPICE PARK(JUL2024)Update 40 models( Solar Cell ) in SPICE PARK(JUL2024)
Update 40 models( Solar Cell ) in SPICE PARK(JUL2024)
 
anatomy of space vehicle and aerospace structures.pptx
anatomy of space vehicle and aerospace structures.pptxanatomy of space vehicle and aerospace structures.pptx
anatomy of space vehicle and aerospace structures.pptx
 
My Aerospace Design and Structures Career Engineering LinkedIn version Presen...
My Aerospace Design and Structures Career Engineering LinkedIn version Presen...My Aerospace Design and Structures Career Engineering LinkedIn version Presen...
My Aerospace Design and Structures Career Engineering LinkedIn version Presen...
 
💋Mature Women / Aunty Call Girls Gurgaon 💯Call Us 🔝 9999965857 🔝💃Independent ...
💋Mature Women / Aunty Call Girls Gurgaon 💯Call Us 🔝 9999965857 🔝💃Independent ...💋Mature Women / Aunty Call Girls Gurgaon 💯Call Us 🔝 9999965857 🔝💃Independent ...
💋Mature Women / Aunty Call Girls Gurgaon 💯Call Us 🔝 9999965857 🔝💃Independent ...
 
Covid Management System Project Report.pdf
Covid Management System Project Report.pdfCovid Management System Project Report.pdf
Covid Management System Project Report.pdf
 
My Airframe Metallic Design Capability Studies..pdf
My Airframe Metallic Design Capability Studies..pdfMy Airframe Metallic Design Capability Studies..pdf
My Airframe Metallic Design Capability Studies..pdf
 
Sri Guru Hargobind Ji - Bandi Chor Guru.pdf
Sri Guru Hargobind Ji - Bandi Chor Guru.pdfSri Guru Hargobind Ji - Bandi Chor Guru.pdf
Sri Guru Hargobind Ji - Bandi Chor Guru.pdf
 
❣Unsatisfied Bhabhi Call Girls Surat 💯Call Us 🔝 7014168258 🔝💃Independent Sura...
❣Unsatisfied Bhabhi Call Girls Surat 💯Call Us 🔝 7014168258 🔝💃Independent Sura...❣Unsatisfied Bhabhi Call Girls Surat 💯Call Us 🔝 7014168258 🔝💃Independent Sura...
❣Unsatisfied Bhabhi Call Girls Surat 💯Call Us 🔝 7014168258 🔝💃Independent Sura...
 
The Differences between Schedule 40 PVC Conduit Pipe and Schedule 80 PVC Conduit
The Differences between Schedule 40 PVC Conduit Pipe and Schedule 80 PVC ConduitThe Differences between Schedule 40 PVC Conduit Pipe and Schedule 80 PVC Conduit
The Differences between Schedule 40 PVC Conduit Pipe and Schedule 80 PVC Conduit
 
❣Independent Call Girls Chennai 💯Call Us 🔝 7737669865 🔝💃Independent Chennai E...
❣Independent Call Girls Chennai 💯Call Us 🔝 7737669865 🔝💃Independent Chennai E...❣Independent Call Girls Chennai 💯Call Us 🔝 7737669865 🔝💃Independent Chennai E...
❣Independent Call Girls Chennai 💯Call Us 🔝 7737669865 🔝💃Independent Chennai E...
 
Basic principle and types Static Relays ppt
Basic principle and  types  Static Relays pptBasic principle and  types  Static Relays ppt
Basic principle and types Static Relays ppt
 
🔥Independent Call Girls In Pune 💯Call Us 🔝 7014168258 🔝💃Independent Pune Esco...
🔥Independent Call Girls In Pune 💯Call Us 🔝 7014168258 🔝💃Independent Pune Esco...🔥Independent Call Girls In Pune 💯Call Us 🔝 7014168258 🔝💃Independent Pune Esco...
🔥Independent Call Girls In Pune 💯Call Us 🔝 7014168258 🔝💃Independent Pune Esco...
 
ESCORT SERVICE FULL ENJOY - @9711199012, Mayur Vihar CALL GIRLS SERVICE Delhi
ESCORT SERVICE FULL ENJOY - @9711199012, Mayur Vihar CALL GIRLS SERVICE DelhiESCORT SERVICE FULL ENJOY - @9711199012, Mayur Vihar CALL GIRLS SERVICE Delhi
ESCORT SERVICE FULL ENJOY - @9711199012, Mayur Vihar CALL GIRLS SERVICE Delhi
 
🚺ANJALI MEHTA High Profile Call Girls Ahmedabad 💯Call Us 🔝 9352988975 🔝💃Top C...
🚺ANJALI MEHTA High Profile Call Girls Ahmedabad 💯Call Us 🔝 9352988975 🔝💃Top C...🚺ANJALI MEHTA High Profile Call Girls Ahmedabad 💯Call Us 🔝 9352988975 🔝💃Top C...
🚺ANJALI MEHTA High Profile Call Girls Ahmedabad 💯Call Us 🔝 9352988975 🔝💃Top C...
 

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")
  翻译: