SlideShare a Scribd company logo
1 of 10
Download to read offline
def main():
print('enter the option')
print('1: celsius to fahrenheit')
print('2: fahrenheit to celsius')
o=int(input('emter the option'))
if(o==1):
c=float(input('emter celsius'))
f=float((9.0/5.0))*c+32
print('fharenheit',f)
else:
f=float(input('enter fharenheit'))
c=float(5.0/9.0)*(f-32.0)
print('celsius',c)
if __name__=='__main__':
main()
1.TEMPERATURE CONVERSION
Print Function & Input Function
Fahrenheit Declared Function
Fahrenheit Declared Function
if…else function
Call Main Funtion
Mr. V. VEERANAN, M.Sc. Computer Science., Dip.in.Yoga.,
def areasquare(a):
area=a*a
return(area)
def arearectangle(l,b):
a=l*b
return(a)
def areacircle(r):
import math
a1=math.pi*r*r
return(a1)
def areatriangle(b,h):
a2=float(0.5*b*h)
return(a2)
def main():
print('enter your option')
print('1. enter area of square')
print('2. enter area of rectangle')
print('3. enter area of circle')
print('4. enter area of triangle')
1 2
2.AREA OF THE SHAPES
Square
Rectangle
Circle
Triangle
Print Function
Mr. V. VEERANAN, M.Sc. Computer Science., Dip.in.Yoga.,
o=int(input('enter your option'))
if(o==1):
a=int(input('enter area'))
x=areasquare(a)
print('area of square',x)
elif(o==2):
l1=int(input('enter length'))
b1=int(input('enter breath'))
y=arearectangle(l1,b1)
print('area of rectangel',y)
elif(o==3):
r=int(input('enter a circle'))
z=areacircle(r)
print('area of circle',z)
elif(o==4):
b1=int(input('enter the breath'))
h1=float(input('enter the heigth'))
aa=areatriangle(b1,h1)
print('area of triangle',aa)
if __name__=='__main__':
main()
3 4
2. AREA OF THE SHAPES
Square
Rectangle
Circle
Triangle
Mr. V. VEERANAN, M.Sc. Computer Science., Dip.in.Yoga.,
def main():
print('enter the marks')
m1=float(input('tamil'))
m2=float(input('english'))
m3=float(input('computer'))
t=m1+m2+m3
p=(t/300)*100
print('mark obtained in tamil',m1)
print('mark obtained in english',m2)
print('mark obtained in computer',m3)
print('total marks in 3 subjects',t)
print('percentage',p)
if(p>=80):
print('grade A')
elif(p>70 and p<80):
print('grade B')
elif(p>60 and p<70):
print('grade C')
elif(p>40 and p<60):
print('grade d')
elif(p<40):
print('grade E')
if __name__=='__main__':
main()
3. PERCENTAGE
Print & Marks
Print
Grade A
Grade B
Grade C
Grade D
Grade E
Mr. V. VEERANAN, M.Sc. Computer Science., Dip.in.Yoga.,
def main():
print('fibonacci series')
n=int(input('enter the range'))
a=1
b=2
print(a)
print(b)
for i in range(n+1):
c=a+b
print(c)
a=b
b=c
if __name__=='__main__':
main()
4. FIBONACCI SERIES
Print & Declare
Print Range
Mr. V. VEERANAN, M.Sc. Computer Science., Dip.in.Yoga.,
def main():
n=int(input('enter the factorial of number:'))
fact=1
for i in range(1,n+1):
fact=fact*1
print('factorial of the number %d is %d',(n,fact))
if __name__=='__main__':
main()
5. FACTORIAL PROGRAM
Input
Print range
Mr. V. VEERANAN, M.Sc. Computer Science., Dip.in.Yoga.,
def facto(n):
fact=1
for i in range(1,n+1):
fact=fact*i
return fact
def main():
n=int(input('enter the value'))
sum=0.0
for i in range(1,n+1):
if(i%2==0):
sum=float(sum)-float(i)/float(facto(i))
else:
sum=float(sum)+float(i)/float(facto(i))
print('sum of the series',round(sum,3))
if __name__=='__main__':
main()
6. SUM OF SERIES
Mr. V. VEERANAN, M.Sc. Computer Science., Dip.in.Yoga.,
Range
Sum
if
else
import matplotlib.pyplot as plt
def plothistogram(data):
plt.hist(data)
plt.xlabel('value')
plt.ylabel('Frequency')
plt.title('histogram')
plt.xlim(min(data)-1,max(data)+1)
plt.show()
def main():
data=eval(input('enter data to be plotted as histogram:'))
plothistogram(data)
if __name__=='__main__':
main()
7. HISTOGRAM
Mr. V. VEERANAN, M.Sc. Computer Science., Dip.in.Yoga.,
Package
Value & Limed
Print
import matplotlib.pyplot as plt
import math
def sinecurve():
plt.subplot(2,1,1)
degrees=range(0,360+1)
sinevalues=[math.sin(math.radians (i))for i in degrees]
plt.plot(sinevalues)
plt.xlabel('degrees')
plt.ylabel('sine value')
plt.title('sine curve')
plt.grid()
8. SINE AND COSINE
Mr. V. VEERANAN, M.Sc. Computer Science., Dip.in.Yoga.,
Package
Sine
def cosinecurve():
plt.subplot(2,1,2)
degrees=range(0,360+1)
cosinevalues=[math.cos(math.radians (i))for i in degrees]
plt.plot(cosinevalues)
plt.xlabel('degrees')
plt.ylabel('cosine value')
plt.title('cosine curve')
plt.grid()
def main():
sinecurve()
cosinecurve()
plt.tight_layout()
plt.show()
if __name__=='__main__':
main()
8. SINE AND COSINE
Mr. V. VEERANAN, M.Sc. Computer Science., Dip.in.Yoga.,
Cosine
Main

More Related Content

Similar to Lab 3 Python Programming Lab 1-8 MKU.pdf

Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...
Mario Fusco
 

Similar to Lab 3 Python Programming Lab 1-8 MKU.pdf (20)

PYTHON_PROGRAM(1-34).pdf
PYTHON_PROGRAM(1-34).pdfPYTHON_PROGRAM(1-34).pdf
PYTHON_PROGRAM(1-34).pdf
 
14 recursion
14 recursion14 recursion
14 recursion
 
Go: It's Not Just For Google
Go: It's Not Just For GoogleGo: It's Not Just For Google
Go: It's Not Just For Google
 
Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...
 
Python programs - first semester computer lab manual (polytechnics)
Python programs - first semester computer lab manual (polytechnics)Python programs - first semester computer lab manual (polytechnics)
Python programs - first semester computer lab manual (polytechnics)
 
Python programs - PPT file (Polytechnics)
Python programs - PPT file (Polytechnics)Python programs - PPT file (Polytechnics)
Python programs - PPT file (Polytechnics)
 
III MCS python lab (1).pdf
III MCS python lab (1).pdfIII MCS python lab (1).pdf
III MCS python lab (1).pdf
 
Python Programming
Python Programming Python Programming
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
 
L25-L26-Parameter passing techniques.pptx
L25-L26-Parameter passing techniques.pptxL25-L26-Parameter passing techniques.pptx
L25-L26-Parameter passing techniques.pptx
 
Forward & Backward Differenece Table
Forward & Backward Differenece TableForward & Backward Differenece Table
Forward & Backward Differenece Table
 
Introductory part of function for class 12th JEE
Introductory part of function for class 12th JEEIntroductory part of function for class 12th JEE
Introductory part of function for class 12th JEE
 
A New Double Numerical Integration Formula Based On The First Order Derivative
A New Double Numerical Integration Formula Based On The First Order DerivativeA New Double Numerical Integration Formula Based On The First Order Derivative
A New Double Numerical Integration Formula Based On The First Order Derivative
 
Python programming workshop session 4
Python programming workshop session 4Python programming workshop session 4
Python programming workshop session 4
 
Opt simple single_000
Opt simple single_000Opt simple single_000
Opt simple single_000
 
ملخص البرمجة المرئية - الوحدة الخامسة
ملخص البرمجة المرئية - الوحدة الخامسةملخص البرمجة المرئية - الوحدة الخامسة
ملخص البرمجة المرئية - الوحدة الخامسة
 
Drinking the free kool-aid
Drinking the free kool-aidDrinking the free kool-aid
Drinking the free kool-aid
 
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
 
6. function
6. function6. function
6. function
 
Implementing the IO Monad in Scala
Implementing the IO Monad in ScalaImplementing the IO Monad in Scala
Implementing the IO Monad in Scala
 

More from CUO VEERANAN VEERANAN

More from CUO VEERANAN VEERANAN (20)

Big Data - large Scale data (Amazon, FB)
Big Data - large Scale data (Amazon, FB)Big Data - large Scale data (Amazon, FB)
Big Data - large Scale data (Amazon, FB)
 
Fourier Transforms are indispensable tool
Fourier Transforms are indispensable toolFourier Transforms are indispensable tool
Fourier Transforms are indispensable tool
 
ENHANCING BIOLOGICAL RESEARCH THROUGH DIGITAL TECHNOLOGIES AND COMPUTATIONAL.ppt
ENHANCING BIOLOGICAL RESEARCH THROUGH DIGITAL TECHNOLOGIES AND COMPUTATIONAL.pptENHANCING BIOLOGICAL RESEARCH THROUGH DIGITAL TECHNOLOGIES AND COMPUTATIONAL.ppt
ENHANCING BIOLOGICAL RESEARCH THROUGH DIGITAL TECHNOLOGIES AND COMPUTATIONAL.ppt
 
ADS_Unit I_Route Map 2023.pdf
ADS_Unit I_Route Map 2023.pdfADS_Unit I_Route Map 2023.pdf
ADS_Unit I_Route Map 2023.pdf
 
CS 23 Operating System Design Principles_MULTIPROCESSOR AND REAL TIME SCHEDULING
CS 23 Operating System Design Principles_MULTIPROCESSOR AND REAL TIME SCHEDULINGCS 23 Operating System Design Principles_MULTIPROCESSOR AND REAL TIME SCHEDULING
CS 23 Operating System Design Principles_MULTIPROCESSOR AND REAL TIME SCHEDULING
 
Python Unit I MCQ.ppt
Python Unit I MCQ.pptPython Unit I MCQ.ppt
Python Unit I MCQ.ppt
 
GAC DS Priority Queue Presentation 2022.ppt
GAC DS Priority Queue Presentation 2022.pptGAC DS Priority Queue Presentation 2022.ppt
GAC DS Priority Queue Presentation 2022.ppt
 
GAC Java Presentation_Server Side Include_Cookies_Filters 2022.ppt
GAC Java Presentation_Server Side Include_Cookies_Filters 2022.pptGAC Java Presentation_Server Side Include_Cookies_Filters 2022.ppt
GAC Java Presentation_Server Side Include_Cookies_Filters 2022.ppt
 
Lab 3 Python Programming Lab 8-15 MKU.pdf
Lab 3 Python Programming Lab 8-15 MKU.pdfLab 3 Python Programming Lab 8-15 MKU.pdf
Lab 3 Python Programming Lab 8-15 MKU.pdf
 
MULTIPROCESSOR AND REAL TIME SCHEDULING.ppt
MULTIPROCESSOR AND REAL TIME SCHEDULING.pptMULTIPROCESSOR AND REAL TIME SCHEDULING.ppt
MULTIPROCESSOR AND REAL TIME SCHEDULING.ppt
 
Relational Algebra.ppt
Relational Algebra.pptRelational Algebra.ppt
Relational Algebra.ppt
 
DS Unit I to III MKU Questions.pdf
DS Unit I to III MKU Questions.pdfDS Unit I to III MKU Questions.pdf
DS Unit I to III MKU Questions.pdf
 
Acharya Vinoba Bhave.ppt
Acharya Vinoba Bhave.pptAcharya Vinoba Bhave.ppt
Acharya Vinoba Bhave.ppt
 
1.1.8 Types of computer & 1.1.8.3 Classification of Computers on the basis of...
1.1.8 Types of computer & 1.1.8.3 Classification of Computers on the basis of...1.1.8 Types of computer & 1.1.8.3 Classification of Computers on the basis of...
1.1.8 Types of computer & 1.1.8.3 Classification of Computers on the basis of...
 
1.1.8 Types of computer & 1.1.8.2 Classification of Computers on the basis of...
1.1.8 Types of computer & 1.1.8.2 Classification of Computers on the basis of...1.1.8 Types of computer & 1.1.8.2 Classification of Computers on the basis of...
1.1.8 Types of computer & 1.1.8.2 Classification of Computers on the basis of...
 
1.1.8 Types of computer & 1.1.8.1 Classification of Computers on the basis of...
1.1.8 Types of computer & 1.1.8.1 Classification of Computers on the basis of...1.1.8 Types of computer & 1.1.8.1 Classification of Computers on the basis of...
1.1.8 Types of computer & 1.1.8.1 Classification of Computers on the basis of...
 
1.1.7 Block diagram and Working Principle of Computer
1.1.7 Block diagram and Working Principle of Computer1.1.7 Block diagram and Working Principle of Computer
1.1.7 Block diagram and Working Principle of Computer
 
1.1.6 Characteristics of Computer
1.1.6 Characteristics of Computer1.1.6 Characteristics of Computer
1.1.6 Characteristics of Computer
 
1.1.5 Terms related to Computer & 1.1.5.3 Technical Industry
1.1.5 Terms related to Computer & 1.1.5.3 Technical Industry1.1.5 Terms related to Computer & 1.1.5.3 Technical Industry
1.1.5 Terms related to Computer & 1.1.5.3 Technical Industry
 
1.1.5 Terms related to Computer & 1.1.5.2 Software.ppt
1.1.5 Terms related to Computer & 1.1.5.2 Software.ppt1.1.5 Terms related to Computer & 1.1.5.2 Software.ppt
1.1.5 Terms related to Computer & 1.1.5.2 Software.ppt
 

Recently uploaded

Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
AnaAcapella
 
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
httgc7rh9c
 

Recently uploaded (20)

OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
What is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptxWhat is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptx
 
Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdf
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdfUGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
 
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
 
How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Our Environment Class 10 Science Notes pdf
Our Environment Class 10 Science Notes pdfOur Environment Class 10 Science Notes pdf
Our Environment Class 10 Science Notes pdf
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf arts
 

Lab 3 Python Programming Lab 1-8 MKU.pdf

  • 1. def main(): print('enter the option') print('1: celsius to fahrenheit') print('2: fahrenheit to celsius') o=int(input('emter the option')) if(o==1): c=float(input('emter celsius')) f=float((9.0/5.0))*c+32 print('fharenheit',f) else: f=float(input('enter fharenheit')) c=float(5.0/9.0)*(f-32.0) print('celsius',c) if __name__=='__main__': main() 1.TEMPERATURE CONVERSION Print Function & Input Function Fahrenheit Declared Function Fahrenheit Declared Function if…else function Call Main Funtion Mr. V. VEERANAN, M.Sc. Computer Science., Dip.in.Yoga.,
  • 2. def areasquare(a): area=a*a return(area) def arearectangle(l,b): a=l*b return(a) def areacircle(r): import math a1=math.pi*r*r return(a1) def areatriangle(b,h): a2=float(0.5*b*h) return(a2) def main(): print('enter your option') print('1. enter area of square') print('2. enter area of rectangle') print('3. enter area of circle') print('4. enter area of triangle') 1 2 2.AREA OF THE SHAPES Square Rectangle Circle Triangle Print Function Mr. V. VEERANAN, M.Sc. Computer Science., Dip.in.Yoga.,
  • 3. o=int(input('enter your option')) if(o==1): a=int(input('enter area')) x=areasquare(a) print('area of square',x) elif(o==2): l1=int(input('enter length')) b1=int(input('enter breath')) y=arearectangle(l1,b1) print('area of rectangel',y) elif(o==3): r=int(input('enter a circle')) z=areacircle(r) print('area of circle',z) elif(o==4): b1=int(input('enter the breath')) h1=float(input('enter the heigth')) aa=areatriangle(b1,h1) print('area of triangle',aa) if __name__=='__main__': main() 3 4 2. AREA OF THE SHAPES Square Rectangle Circle Triangle Mr. V. VEERANAN, M.Sc. Computer Science., Dip.in.Yoga.,
  • 4. def main(): print('enter the marks') m1=float(input('tamil')) m2=float(input('english')) m3=float(input('computer')) t=m1+m2+m3 p=(t/300)*100 print('mark obtained in tamil',m1) print('mark obtained in english',m2) print('mark obtained in computer',m3) print('total marks in 3 subjects',t) print('percentage',p) if(p>=80): print('grade A') elif(p>70 and p<80): print('grade B') elif(p>60 and p<70): print('grade C') elif(p>40 and p<60): print('grade d') elif(p<40): print('grade E') if __name__=='__main__': main() 3. PERCENTAGE Print & Marks Print Grade A Grade B Grade C Grade D Grade E Mr. V. VEERANAN, M.Sc. Computer Science., Dip.in.Yoga.,
  • 5. def main(): print('fibonacci series') n=int(input('enter the range')) a=1 b=2 print(a) print(b) for i in range(n+1): c=a+b print(c) a=b b=c if __name__=='__main__': main() 4. FIBONACCI SERIES Print & Declare Print Range Mr. V. VEERANAN, M.Sc. Computer Science., Dip.in.Yoga.,
  • 6. def main(): n=int(input('enter the factorial of number:')) fact=1 for i in range(1,n+1): fact=fact*1 print('factorial of the number %d is %d',(n,fact)) if __name__=='__main__': main() 5. FACTORIAL PROGRAM Input Print range Mr. V. VEERANAN, M.Sc. Computer Science., Dip.in.Yoga.,
  • 7. def facto(n): fact=1 for i in range(1,n+1): fact=fact*i return fact def main(): n=int(input('enter the value')) sum=0.0 for i in range(1,n+1): if(i%2==0): sum=float(sum)-float(i)/float(facto(i)) else: sum=float(sum)+float(i)/float(facto(i)) print('sum of the series',round(sum,3)) if __name__=='__main__': main() 6. SUM OF SERIES Mr. V. VEERANAN, M.Sc. Computer Science., Dip.in.Yoga., Range Sum if else
  • 8. import matplotlib.pyplot as plt def plothistogram(data): plt.hist(data) plt.xlabel('value') plt.ylabel('Frequency') plt.title('histogram') plt.xlim(min(data)-1,max(data)+1) plt.show() def main(): data=eval(input('enter data to be plotted as histogram:')) plothistogram(data) if __name__=='__main__': main() 7. HISTOGRAM Mr. V. VEERANAN, M.Sc. Computer Science., Dip.in.Yoga., Package Value & Limed Print
  • 9. import matplotlib.pyplot as plt import math def sinecurve(): plt.subplot(2,1,1) degrees=range(0,360+1) sinevalues=[math.sin(math.radians (i))for i in degrees] plt.plot(sinevalues) plt.xlabel('degrees') plt.ylabel('sine value') plt.title('sine curve') plt.grid() 8. SINE AND COSINE Mr. V. VEERANAN, M.Sc. Computer Science., Dip.in.Yoga., Package Sine
  • 10. def cosinecurve(): plt.subplot(2,1,2) degrees=range(0,360+1) cosinevalues=[math.cos(math.radians (i))for i in degrees] plt.plot(cosinevalues) plt.xlabel('degrees') plt.ylabel('cosine value') plt.title('cosine curve') plt.grid() def main(): sinecurve() cosinecurve() plt.tight_layout() plt.show() if __name__=='__main__': main() 8. SINE AND COSINE Mr. V. VEERANAN, M.Sc. Computer Science., Dip.in.Yoga., Cosine Main