SlideShare ist ein Scribd-Unternehmen logo
1 von 12
Lecture 1:- print, id, type, basic data type (integer, float, string)
print('this is first python class') #this is first python class
print("hello student");print("welcome at inception") #hello student #welcome at inception
# This is single line comment
'''
this is multiline comment
welcome at inception.
'''
a=10
print(type(a)) #<class 'int'>
b=12.2
print(type(b)) #<class 'float'>
c='hello'
print(type(c)) #<class 'str'>
d="hello"
print(type(d)) #<class 'str'>
e='''hello
how are you'''
print(type(e)) #<class 'str'> #used for multiline string
f="""hello
how are you"""
print(type(f)) #<class 'str'> #used for multiline string
g=10
print(type(g)) #<class 'int'>
#id of a and e is equal because both refer to same value
#so value are stored at one place rather than multiple place
#same concept are used in facebook for photo storing
print(id(a)) #1522298624
print(id(g)) #1522298624
print(id(b)) #2240465414760
print(id(c)) #2321848675664
print(id(d)) #2321848675664
print(id(e)) #2321848802664
print(id(f)) #2321848802664
n=input("Enter any number")
print(type(n))
#Enter any number11
#<class 'str'>
n=int(input("Enter any number"))
print(type(n))
#Enter any number12
#<class 'int'>
n=float(input("Enter any number"))
print(type(n))
#Enter any number2.3
#<class 'float'>
a=10
b=20
print(id(a)==id(b))
#False
c=10
print(id(a)==id(c))
#True
Lecture 2:- multi datatype declaration, input, eval, sqrt, fabs, comparison operators,if,else
#this is single line comment
a=b=10
print(a,b)
#10 10
#swap of two number
a,b=10,20
a,b=b,a
print("a:",a,"b:",b)
#a: 20 b: 10
#swap of two number
a=eval(input("enter first number"))
b=eval(input("enter first number"))
x,y=a,b
a,b=b,a
print("value of", x, "and", y, "after swap",a,b)
#enter first number10
#enter first number20
#value of 10 and 20 after swap 20 10
#temperature in Celsius and Fahrenheit
c=eval(input("enter temperature in Celsius"))
f=((9/5)*c)+32
print("temperature in Celsius", c,"is",f,"in Fahrenheit")
#enter temperature in celcius37
#temperature in Celsius 37 is 98.60000000000001 in Fahrenheit
c=(f-32)*(5/9)
print("temperature in fahernite",f,"is",c, "in celcius")
#temperature in fahernite 98.60000000000001 is 37.00000000000001 in celcius
print(9/5) #1.8
print(9//5) #1
import math
a=math.sqrt(4)
print(a) #2.0
from math import sqrt
a=sqrt(4)
print(a) #2.0
#find hypotenuse of triangle
b=eval(input("enter base of triangle"))
h=eval(input("enter height of triangle"))
import math
hy=math.sqrt(h*h+b*b)
print("hypotenuse of triangle with height",h,"and base",b,"is",hy)
#enter base of triangle3
#enter height of triangle4
#hypotenuse of triangle with height 4 and base 3 is 5.0
#find hypotenuse of triangle
from math import sqrt
hy=sqrt(h*h+b*b)
print("hypotenuse of triangle with height", h, "and base",b,"is",hy)
#hypotenuse of triangle with height 4 and base 3 is 5.0
from math import fabs
a=fabs(-4)
print(a) #4.0
#comparison operators
a=eval(input("enter first number:"))
b=eval(input("enter second number:"))
if(a<b):
print("a=",a,"is less than b=",b)
if(a>b):
print("b=",b," is less than a=",a)
if(a==b):
print("b=",b," is equal to a=",a)
if(a<=b):
print("b=",b," is less or equal to a=",a)
if(a>=b):
print("b=",b," is greater than or equal to a=",a)
if(a!=b):
print("b=",b," is not equal to a=",a)
#b= 10 is less than a= 50
#b= 10 is greater than or equal to a= 50
#b= 10 is not equal to a= 50
Lecture 3: String, id, while, end
print('He said,"Ram is honest"')
#He said,"Ram is honest"
#string
s='hello'
print(s,type(s)) #hello <class 'str'>
s1="hello"
print(s1,type(s1)) #hello <class 'str'>
s2='''hello'''
print(s2,type(s2)) #hello <class 'str'>
s3="""hello"""
print(s3,type(s3)) #hello <class 'str'>
s="hello inception"
print(s[3:5]) #lo
print(s[6:15]) #inception
print(s[-1:]) #n
s="Hello Inception"
#slicing of string
s="Hello Inception"
print(s[6:-1])
#'Inceptio'
print(s[-1:-10])
#'' print nothing
print(s[-1:-9])
#'' print nothing
print(s[-9:-1])
#'Inceptio'
print(s[14:0])
#'' print nothing
#while loop
i=1
while(i<=10):
print(i,end=" ") #print value in one line
i=i+1
else:
print("bye")
#perfect square
from math import sqrt
a=eval(input("enter any number"))
b=sqrt(a)
if(a==b*b):
print(a,"is a perfect square")
else:
print(a,"is not perfect square")
#enter any number25
#25 is a perfect square
Lecture 4: for loop, and, or
for i in range(0,5):
print(i, end=" ")
#0 1 2 3 4
for i in range(0,10,2):
print(i,end=" ")
#0 2 4 6 8
for i in range(10,0,-2):
print("n",i,end=",")
#10,8,6,4,2
a=10
b=20
c=10
if(a!=c) or (b<a):
print('hi')
else:
print("hello")
#hello
#largest of three number
a=eval(input("enter first no."))
b=eval(input("enter second no."))
c=eval(input("enter third no."))
if(a>b) and (a>c):
print(a,"is largest")
else:
if(b>a) and (b>c):
print(b,"is largest")
else:
print("c is largest")
#leap year
y=eval(input("Enter year"))
if (y%4==0):
if(y%100==0):
if(y%400==0):
print("leap year")
else:
print("not leap year")
else:
print("leap year")
else:
print("not leap year")
#check number power of 3
n=eval(input("enter number"))
while(n%3==0):
n=n/3
if(n==1):
print("power of 3")
else:
print("not power of 3")
Lecture 5: for loop break, continue and pass
# check if an integer is power of another integer
n1=eval(input("Enter integer"))
n2=eval(input("ckeck for integer"))
while(n1%n2==0):
n1=n1/n2
if(n1==1):
print("power of ",n2)
else:
print("not power of ",n2)
#break demonstration
for i in range(14):
if(i==5):
break
print(i)
print("good bye")
#continue demonstration
for i in range(14):
if(i==5):
continue
print(i)
print("good bye")
#pass demonstration
for letter in 'python':
if (letter=='h'):
pass
print("this is pass")
print("current letter",letter)
print("bye")
hggggggg
#sum of N number
n=eval(input("Enter no."))
sum=0
for i in range(0,n+1):
sum=sum+i
#print(sum)
print("Sum is:",sum)
#Enter no.10
#Sum is:55
#sum of evenand odd number up to N
n=eval(input("Enter the numbers"))
even=0
odd=0
for i in range(0,n+1):
if(i%2==0):
even=even+i
else:
odd=odd+i
print("Sum of even numbers",even)
print("sum of odd numbers",odd)
#Enter the numbers34
#Sum of even numbers 306
#sum of odd numbers 289
#user defined function
def hello():
print("hello") #hello
hello()
#typical question
#add the digits of a positive integer repeatedly until the result has a single digit
def addsum(n):
s=0
while(n>0 or s>9):
if(n==0):
n=s
#print(n)
s=0
s=s+n%10
n=n//10
return s
n=eval(input("Enter any number:"))
print("sum in single digits ",addsum(n))
#Enter any number:65
#sum in single digits 2
Lecture 6: for loop, break, continue, recursion, chr and ord
#find factorial of number with recursion
def factorial(n):
if(n==1):
return 1
else:
return (n*factorial(n-1))
n=eval(input("Enter number:"))
if(n<0):
print("not valid")
elif(n==0 or n==1):
print("Factorial of",n,"is",1)
else:
print("Factorial of ",n,"is",factorial(n))
#Enter number:12
#Factorial of 12 is 479001600
#find factorial of number without recursion
n=eval(input("Enter number"))
if(n<0):
print("not valid")
elif(n==0 or n==1):
print("Factorial of",n,"is",1)
else:
f=1
while(n>1):
f=f*n
n=n-1
print("Factorial is",f)
#Enter number:12
#Factorial of 12 is 479001600
#chr and ord function
print(chr(97))
#'a'
print(ord('a'))
#97
#generate random password
c=''
for i in range(33, 128):
c=c+chr(i)
#print(c)
from random import choice
n=eval(input("Enter length of password"))
p=eval(input("Enter no. of passwords"))
print("Generated password is:")
for i in range(p):
password=''
for i in range(n):
password+=choice(c)
print(password)
#Enter length of password12
#Enter no. of passwords3
#Generated password is:
#b[&b_(2(9FMY
#=$4V29wn(A%$
#oLI3`J:lnQBf

Weitere ähnliche Inhalte

Was ist angesagt?

C Programming Language Part 8
C Programming Language Part 8C Programming Language Part 8
C Programming Language Part 8Rumman Ansari
 
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solutionAzhar Javed
 
Core programming in c
Core programming in cCore programming in c
Core programming in cRahul Pandit
 
Chapter 5 Balagurusamy Programming ANSI in c
Chapter 5 Balagurusamy Programming ANSI  in cChapter 5 Balagurusamy Programming ANSI  in c
Chapter 5 Balagurusamy Programming ANSI in cBUBT
 
Chapter 6 Balagurusamy Programming ANSI in c
Chapter 6  Balagurusamy Programming ANSI  in cChapter 6  Balagurusamy Programming ANSI  in c
Chapter 6 Balagurusamy Programming ANSI in cBUBT
 
Chapter 5 exercises Balagurusamy Programming ANSI in c
Chapter 5 exercises Balagurusamy Programming ANSI  in cChapter 5 exercises Balagurusamy Programming ANSI  in c
Chapter 5 exercises Balagurusamy Programming ANSI in cBUBT
 
Chapter 4 : Balagurusamy Programming ANSI in C
Chapter 4 : Balagurusamy Programming ANSI in CChapter 4 : Balagurusamy Programming ANSI in C
Chapter 4 : Balagurusamy Programming ANSI in CBUBT
 
C Programming Language Step by Step Part 5
C Programming Language Step by Step Part 5C Programming Language Step by Step Part 5
C Programming Language Step by Step Part 5Rumman Ansari
 
Chapter 2 : Balagurusamy_ Programming ANsI in C
Chapter 2 :  Balagurusamy_ Programming ANsI in CChapter 2 :  Balagurusamy_ Programming ANsI in C
Chapter 2 : Balagurusamy_ Programming ANsI in CBUBT
 
Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020vrgokila
 
Let us c (by yashvant kanetkar) chapter 1 solution
Let us c (by yashvant kanetkar) chapter 1 solutionLet us c (by yashvant kanetkar) chapter 1 solution
Let us c (by yashvant kanetkar) chapter 1 solutionHazrat Bilal
 
Php in the graph (Gremlin 3)
Php in the graph (Gremlin 3)Php in the graph (Gremlin 3)
Php in the graph (Gremlin 3)Damien Seguy
 
Let us c(by yashwant kanetkar) chapter 2 solution
Let us c(by yashwant kanetkar) chapter 2 solutionLet us c(by yashwant kanetkar) chapter 2 solution
Let us c(by yashwant kanetkar) chapter 2 solutionrohit kumar
 
Aplikasi menghitung matematika dengan c++
Aplikasi menghitung matematika dengan c++Aplikasi menghitung matematika dengan c++
Aplikasi menghitung matematika dengan c++radar radius
 

Was ist angesagt? (20)

C Programming Language Part 8
C Programming Language Part 8C Programming Language Part 8
C Programming Language Part 8
 
Ansi c
Ansi cAnsi c
Ansi c
 
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solution
 
Core programming in c
Core programming in cCore programming in c
Core programming in c
 
Chapter 5 Balagurusamy Programming ANSI in c
Chapter 5 Balagurusamy Programming ANSI  in cChapter 5 Balagurusamy Programming ANSI  in c
Chapter 5 Balagurusamy Programming ANSI in c
 
Chapter 6 Balagurusamy Programming ANSI in c
Chapter 6  Balagurusamy Programming ANSI  in cChapter 6  Balagurusamy Programming ANSI  in c
Chapter 6 Balagurusamy Programming ANSI in c
 
Chapter 5 exercises Balagurusamy Programming ANSI in c
Chapter 5 exercises Balagurusamy Programming ANSI  in cChapter 5 exercises Balagurusamy Programming ANSI  in c
Chapter 5 exercises Balagurusamy Programming ANSI in c
 
C programming
C programmingC programming
C programming
 
BCSL 058 solved assignment
BCSL 058 solved assignmentBCSL 058 solved assignment
BCSL 058 solved assignment
 
Chapter 4 : Balagurusamy Programming ANSI in C
Chapter 4 : Balagurusamy Programming ANSI in CChapter 4 : Balagurusamy Programming ANSI in C
Chapter 4 : Balagurusamy Programming ANSI in C
 
C Programming Language Step by Step Part 5
C Programming Language Step by Step Part 5C Programming Language Step by Step Part 5
C Programming Language Step by Step Part 5
 
Chapter 2 : Balagurusamy_ Programming ANsI in C
Chapter 2 :  Balagurusamy_ Programming ANsI in CChapter 2 :  Balagurusamy_ Programming ANsI in C
Chapter 2 : Balagurusamy_ Programming ANsI in C
 
Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020
 
Vcs17
Vcs17Vcs17
Vcs17
 
Let us c (by yashvant kanetkar) chapter 1 solution
Let us c (by yashvant kanetkar) chapter 1 solutionLet us c (by yashvant kanetkar) chapter 1 solution
Let us c (by yashvant kanetkar) chapter 1 solution
 
C lab manaual
C lab manaualC lab manaual
C lab manaual
 
Php in the graph (Gremlin 3)
Php in the graph (Gremlin 3)Php in the graph (Gremlin 3)
Php in the graph (Gremlin 3)
 
Let us c(by yashwant kanetkar) chapter 2 solution
Let us c(by yashwant kanetkar) chapter 2 solutionLet us c(by yashwant kanetkar) chapter 2 solution
Let us c(by yashwant kanetkar) chapter 2 solution
 
Aplikasi menghitung matematika dengan c++
Aplikasi menghitung matematika dengan c++Aplikasi menghitung matematika dengan c++
Aplikasi menghitung matematika dengan c++
 
Matlab code for secant method
Matlab code for secant methodMatlab code for secant method
Matlab code for secant method
 

Ähnlich wie Python real time tutorial

fds Practicle 1to 6 program.pdf
fds Practicle 1to 6 program.pdffds Practicle 1to 6 program.pdf
fds Practicle 1to 6 program.pdfGaneshPawar819187
 
Xi CBSE Computer Science lab programs
Xi CBSE Computer Science lab programsXi CBSE Computer Science lab programs
Xi CBSE Computer Science lab programsProf. Dr. K. Adisesha
 
III MCS python lab (1).pdf
III MCS python lab (1).pdfIII MCS python lab (1).pdf
III MCS python lab (1).pdfsrxerox
 
Class 2: Welcome part 2
Class 2: Welcome part 2Class 2: Welcome part 2
Class 2: Welcome part 2Marc Gouw
 
The groovy puzzlers (as Presented at JavaOne 2014)
The groovy puzzlers (as Presented at JavaOne 2014)The groovy puzzlers (as Presented at JavaOne 2014)
The groovy puzzlers (as Presented at JavaOne 2014)GroovyPuzzlers
 
data structure and algorithm.pdf
data structure and algorithm.pdfdata structure and algorithm.pdf
data structure and algorithm.pdfAsrinath1
 
Sharable_Java_Python.pdf
Sharable_Java_Python.pdfSharable_Java_Python.pdf
Sharable_Java_Python.pdfICADCMLTPC
 
GE8151 Problem Solving and Python Programming
GE8151 Problem Solving and Python ProgrammingGE8151 Problem Solving and Python Programming
GE8151 Problem Solving and Python ProgrammingMuthu Vinayagam
 
python practicals-solution-2019-20-class-xii.pdf
python practicals-solution-2019-20-class-xii.pdfpython practicals-solution-2019-20-class-xii.pdf
python practicals-solution-2019-20-class-xii.pdfrajatxyz
 
Idiomatic Kotlin
Idiomatic KotlinIdiomatic Kotlin
Idiomatic Kotlinintelliyole
 
3 kotlin vs. java- what kotlin has that java does not
3  kotlin vs. java- what kotlin has that java does not3  kotlin vs. java- what kotlin has that java does not
3 kotlin vs. java- what kotlin has that java does notSergey Bandysik
 
Assignment on Numerical Method C Code
Assignment on Numerical Method C CodeAssignment on Numerical Method C Code
Assignment on Numerical Method C CodeSyed Ahmed Zaki
 
Swift 5.1 Language Guide Notes.pdf
Swift 5.1 Language Guide Notes.pdfSwift 5.1 Language Guide Notes.pdf
Swift 5.1 Language Guide Notes.pdfJkPoppy
 

Ähnlich wie Python real time tutorial (20)

Practicle 1.docx
Practicle 1.docxPracticle 1.docx
Practicle 1.docx
 
fds Practicle 1to 6 program.pdf
fds Practicle 1to 6 program.pdffds Practicle 1to 6 program.pdf
fds Practicle 1to 6 program.pdf
 
Xi CBSE Computer Science lab programs
Xi CBSE Computer Science lab programsXi CBSE Computer Science lab programs
Xi CBSE Computer Science lab programs
 
ECE-PYTHON.docx
ECE-PYTHON.docxECE-PYTHON.docx
ECE-PYTHON.docx
 
III MCS python lab (1).pdf
III MCS python lab (1).pdfIII MCS python lab (1).pdf
III MCS python lab (1).pdf
 
Class 2: Welcome part 2
Class 2: Welcome part 2Class 2: Welcome part 2
Class 2: Welcome part 2
 
The groovy puzzlers (as Presented at JavaOne 2014)
The groovy puzzlers (as Presented at JavaOne 2014)The groovy puzzlers (as Presented at JavaOne 2014)
The groovy puzzlers (as Presented at JavaOne 2014)
 
data structure and algorithm.pdf
data structure and algorithm.pdfdata structure and algorithm.pdf
data structure and algorithm.pdf
 
Sharable_Java_Python.pdf
Sharable_Java_Python.pdfSharable_Java_Python.pdf
Sharable_Java_Python.pdf
 
GE8151 Problem Solving and Python Programming
GE8151 Problem Solving and Python ProgrammingGE8151 Problem Solving and Python Programming
GE8151 Problem Solving and Python Programming
 
python practicals-solution-2019-20-class-xii.pdf
python practicals-solution-2019-20-class-xii.pdfpython practicals-solution-2019-20-class-xii.pdf
python practicals-solution-2019-20-class-xii.pdf
 
Idiomatic Kotlin
Idiomatic KotlinIdiomatic Kotlin
Idiomatic Kotlin
 
VTU Data Structures Lab Manual
VTU Data Structures Lab ManualVTU Data Structures Lab Manual
VTU Data Structures Lab Manual
 
3 kotlin vs. java- what kotlin has that java does not
3  kotlin vs. java- what kotlin has that java does not3  kotlin vs. java- what kotlin has that java does not
3 kotlin vs. java- what kotlin has that java does not
 
python codes
python codespython codes
python codes
 
Programs.doc
Programs.docPrograms.doc
Programs.doc
 
AI-Programs.pdf
AI-Programs.pdfAI-Programs.pdf
AI-Programs.pdf
 
notes.pdf
notes.pdfnotes.pdf
notes.pdf
 
Assignment on Numerical Method C Code
Assignment on Numerical Method C CodeAssignment on Numerical Method C Code
Assignment on Numerical Method C Code
 
Swift 5.1 Language Guide Notes.pdf
Swift 5.1 Language Guide Notes.pdfSwift 5.1 Language Guide Notes.pdf
Swift 5.1 Language Guide Notes.pdf
 

Kürzlich hochgeladen

Comparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization TechniquesComparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization Techniquesugginaramesh
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)Dr SOUNDIRARAJ N
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catcherssdickerson1
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfAsst.prof M.Gokilavani
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
An introduction to Semiconductor and its types.pptx
An introduction to Semiconductor and its types.pptxAn introduction to Semiconductor and its types.pptx
An introduction to Semiconductor and its types.pptxPurva Nikam
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncssuser2ae721
 
computer application and construction management
computer application and construction managementcomputer application and construction management
computer application and construction managementMariconPadriquez1
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 

Kürzlich hochgeladen (20)

Comparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization TechniquesComparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization Techniques
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
 
young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
An introduction to Semiconductor and its types.pptx
An introduction to Semiconductor and its types.pptxAn introduction to Semiconductor and its types.pptx
An introduction to Semiconductor and its types.pptx
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
 
computer application and construction management
computer application and construction managementcomputer application and construction management
computer application and construction management
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
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
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 

Python real time tutorial

  • 1. Lecture 1:- print, id, type, basic data type (integer, float, string) print('this is first python class') #this is first python class print("hello student");print("welcome at inception") #hello student #welcome at inception # This is single line comment ''' this is multiline comment welcome at inception. ''' a=10 print(type(a)) #<class 'int'> b=12.2 print(type(b)) #<class 'float'> c='hello' print(type(c)) #<class 'str'> d="hello" print(type(d)) #<class 'str'> e='''hello how are you''' print(type(e)) #<class 'str'> #used for multiline string f="""hello how are you""" print(type(f)) #<class 'str'> #used for multiline string g=10 print(type(g)) #<class 'int'> #id of a and e is equal because both refer to same value #so value are stored at one place rather than multiple place #same concept are used in facebook for photo storing print(id(a)) #1522298624 print(id(g)) #1522298624 print(id(b)) #2240465414760 print(id(c)) #2321848675664 print(id(d)) #2321848675664 print(id(e)) #2321848802664 print(id(f)) #2321848802664 n=input("Enter any number") print(type(n)) #Enter any number11 #<class 'str'> n=int(input("Enter any number")) print(type(n)) #Enter any number12
  • 2. #<class 'int'> n=float(input("Enter any number")) print(type(n)) #Enter any number2.3 #<class 'float'> a=10 b=20 print(id(a)==id(b)) #False c=10 print(id(a)==id(c)) #True
  • 3. Lecture 2:- multi datatype declaration, input, eval, sqrt, fabs, comparison operators,if,else #this is single line comment a=b=10 print(a,b) #10 10 #swap of two number a,b=10,20 a,b=b,a print("a:",a,"b:",b) #a: 20 b: 10 #swap of two number a=eval(input("enter first number")) b=eval(input("enter first number")) x,y=a,b a,b=b,a print("value of", x, "and", y, "after swap",a,b) #enter first number10 #enter first number20 #value of 10 and 20 after swap 20 10 #temperature in Celsius and Fahrenheit c=eval(input("enter temperature in Celsius")) f=((9/5)*c)+32 print("temperature in Celsius", c,"is",f,"in Fahrenheit") #enter temperature in celcius37 #temperature in Celsius 37 is 98.60000000000001 in Fahrenheit c=(f-32)*(5/9) print("temperature in fahernite",f,"is",c, "in celcius") #temperature in fahernite 98.60000000000001 is 37.00000000000001 in celcius print(9/5) #1.8 print(9//5) #1 import math a=math.sqrt(4) print(a) #2.0 from math import sqrt a=sqrt(4) print(a) #2.0 #find hypotenuse of triangle b=eval(input("enter base of triangle")) h=eval(input("enter height of triangle")) import math
  • 4. hy=math.sqrt(h*h+b*b) print("hypotenuse of triangle with height",h,"and base",b,"is",hy) #enter base of triangle3 #enter height of triangle4 #hypotenuse of triangle with height 4 and base 3 is 5.0 #find hypotenuse of triangle from math import sqrt hy=sqrt(h*h+b*b) print("hypotenuse of triangle with height", h, "and base",b,"is",hy) #hypotenuse of triangle with height 4 and base 3 is 5.0 from math import fabs a=fabs(-4) print(a) #4.0 #comparison operators a=eval(input("enter first number:")) b=eval(input("enter second number:")) if(a<b): print("a=",a,"is less than b=",b) if(a>b): print("b=",b," is less than a=",a) if(a==b): print("b=",b," is equal to a=",a) if(a<=b): print("b=",b," is less or equal to a=",a) if(a>=b): print("b=",b," is greater than or equal to a=",a) if(a!=b): print("b=",b," is not equal to a=",a) #b= 10 is less than a= 50 #b= 10 is greater than or equal to a= 50 #b= 10 is not equal to a= 50
  • 5. Lecture 3: String, id, while, end print('He said,"Ram is honest"') #He said,"Ram is honest" #string s='hello' print(s,type(s)) #hello <class 'str'> s1="hello" print(s1,type(s1)) #hello <class 'str'> s2='''hello''' print(s2,type(s2)) #hello <class 'str'> s3="""hello""" print(s3,type(s3)) #hello <class 'str'> s="hello inception" print(s[3:5]) #lo print(s[6:15]) #inception print(s[-1:]) #n s="Hello Inception" #slicing of string s="Hello Inception" print(s[6:-1]) #'Inceptio' print(s[-1:-10]) #'' print nothing print(s[-1:-9]) #'' print nothing print(s[-9:-1]) #'Inceptio' print(s[14:0]) #'' print nothing #while loop i=1 while(i<=10): print(i,end=" ") #print value in one line i=i+1 else: print("bye") #perfect square from math import sqrt a=eval(input("enter any number")) b=sqrt(a) if(a==b*b):
  • 6. print(a,"is a perfect square") else: print(a,"is not perfect square") #enter any number25 #25 is a perfect square
  • 7. Lecture 4: for loop, and, or for i in range(0,5): print(i, end=" ") #0 1 2 3 4 for i in range(0,10,2): print(i,end=" ") #0 2 4 6 8 for i in range(10,0,-2): print("n",i,end=",") #10,8,6,4,2 a=10 b=20 c=10 if(a!=c) or (b<a): print('hi') else: print("hello") #hello #largest of three number a=eval(input("enter first no.")) b=eval(input("enter second no.")) c=eval(input("enter third no.")) if(a>b) and (a>c): print(a,"is largest") else: if(b>a) and (b>c): print(b,"is largest") else: print("c is largest") #leap year y=eval(input("Enter year")) if (y%4==0): if(y%100==0): if(y%400==0): print("leap year") else: print("not leap year") else: print("leap year") else: print("not leap year")
  • 8. #check number power of 3 n=eval(input("enter number")) while(n%3==0): n=n/3 if(n==1): print("power of 3") else: print("not power of 3")
  • 9. Lecture 5: for loop break, continue and pass # check if an integer is power of another integer n1=eval(input("Enter integer")) n2=eval(input("ckeck for integer")) while(n1%n2==0): n1=n1/n2 if(n1==1): print("power of ",n2) else: print("not power of ",n2) #break demonstration for i in range(14): if(i==5): break print(i) print("good bye") #continue demonstration for i in range(14): if(i==5): continue print(i) print("good bye") #pass demonstration for letter in 'python': if (letter=='h'): pass print("this is pass") print("current letter",letter) print("bye") hggggggg #sum of N number n=eval(input("Enter no.")) sum=0 for i in range(0,n+1): sum=sum+i #print(sum) print("Sum is:",sum) #Enter no.10 #Sum is:55 #sum of evenand odd number up to N n=eval(input("Enter the numbers")) even=0
  • 10. odd=0 for i in range(0,n+1): if(i%2==0): even=even+i else: odd=odd+i print("Sum of even numbers",even) print("sum of odd numbers",odd) #Enter the numbers34 #Sum of even numbers 306 #sum of odd numbers 289 #user defined function def hello(): print("hello") #hello hello() #typical question #add the digits of a positive integer repeatedly until the result has a single digit def addsum(n): s=0 while(n>0 or s>9): if(n==0): n=s #print(n) s=0 s=s+n%10 n=n//10 return s n=eval(input("Enter any number:")) print("sum in single digits ",addsum(n)) #Enter any number:65 #sum in single digits 2
  • 11. Lecture 6: for loop, break, continue, recursion, chr and ord #find factorial of number with recursion def factorial(n): if(n==1): return 1 else: return (n*factorial(n-1)) n=eval(input("Enter number:")) if(n<0): print("not valid") elif(n==0 or n==1): print("Factorial of",n,"is",1) else: print("Factorial of ",n,"is",factorial(n)) #Enter number:12 #Factorial of 12 is 479001600 #find factorial of number without recursion n=eval(input("Enter number")) if(n<0): print("not valid") elif(n==0 or n==1): print("Factorial of",n,"is",1) else: f=1 while(n>1): f=f*n n=n-1 print("Factorial is",f) #Enter number:12 #Factorial of 12 is 479001600 #chr and ord function print(chr(97)) #'a' print(ord('a')) #97 #generate random password c='' for i in range(33, 128): c=c+chr(i) #print(c) from random import choice n=eval(input("Enter length of password"))
  • 12. p=eval(input("Enter no. of passwords")) print("Generated password is:") for i in range(p): password='' for i in range(n): password+=choice(c) print(password) #Enter length of password12 #Enter no. of passwords3 #Generated password is: #b[&b_(2(9FMY #=$4V29wn(A%$ #oLI3`J:lnQBf