SlideShare a Scribd company logo
1 of 11
Download to read offline
9. 3D ANIMATION
Mr. V. VEERANAN, M.Sc. Computer Science., Dip.in.Yoga.,
from vpython import *
def show_curve():
curve(x=arange(100), y=arange(100)**0.5, color=color.red)
def show_sphere():
ball = sphere(pos=vector(1,2,1), radius=0.5)
def show_cone():
cone(textures=textures.stucco,axis=vector(-1,4,0),up=vector(1,2,2,))
def show_arrow():
arrow(pos=vector(-2,0,0),color=vector(1,0,1),axis=vector(1,2,2),up=vector(-1,5,2))
def show_rings():
ring(pos=vector(1, 1, 1), axis=vector(0, 1, 0), radius=0.5, thickness=0.1)
def show_cylinder():
rod= cylinder(pos=vector(0, 2, 1), axis=vector(5, 0, 0), radius=1)
Curve
Sphere
Cone
Arrow
Rings
Cylinder
9. 3D ANIMATION
Mr. V. VEERANAN, M.Sc. Computer Science., Dip.in.Yoga.,
def menu():
print('1. Curve')
print('2. Sphere')
print('3. Cone')
print('4. Arrow')
print('5. Rings')
print('6. Cylinder')
ch= 'y'
while(ch=='y'):
menu()
choice = int(input('Enter choice..'))
if(choice == 1):
show_curve()
elif(choice == 2):
show_sphere()
elif(choice == 3):
show_cone()
elif(choice == 4):
show_arrow()
elif(choice == 5):
show_rings()
elif(choice == 6):
show_cylinder()
else:
print('Wrong choice')
ch= input('Do you want to continue (y/n)...')
Print
Menu
Curve
Sphere
Cone
Arrow
Rings
Cylinder
else Print
10. PULSE Vs HEIGHT
Mr. V. VEERANAN, M.Sc. Computer Science., Dip.in.Yoga.,
import matplotlib.pyplot as plt
n=int(input('enter the number of people:'))
p=[]
h=[]
for i in range(n):
p_i=int(input(f"enter pulse rate of person{i+1}:"))
h_i=int(input(f"enter height no of person{i+1}:"))
p.append(p_i)
h.append(h_i)
plt.scatter(h,p)
plt.title("pulse rate vs height")
plt.xlabel("height(cm)")
plt.ylabel("pusle rate(bpm)")
plt.show()
if __name__=='__main__':
main()
Package & init
p, h Declared
Label & Value
11. MASS Vs TIME
Mr. V. VEERANAN, M.Sc. Computer Science., Dip.in.Yoga.,
import matplotlib.pyplot as plt
def calculate_mass(t):
return 60/(t+2)
time_values = [i*0.5 for i in range(21)]
mass_values = [calculate_mass(t) for t in time_values]
plt.plot(time_values, mass_values)
plt.title('Graph of t vs. m')
plt.xlabel('Time (hours)')
plt.ylabel('Mass (grams)')
plt.show()
Package & Calculation
Label & Values
12. PASSWORD
Mr. V. VEERANAN, M.Sc. Computer Science., Dip.in.Yoga.,
import re
p=input("Input your password:")
x=True
while x:
if(len(p)<6 or len(p)>12):
break
elif not re.search("[a-z]",p):
break
elif not re.search("[0-9]",p):
break
elif not re.search("[A-Z]",p):
break
elif not re.search("[$#@]",p):
break
elif not re.search("s",p):
break
else:
print("valid password")
x=False
break
if x:
print("Not a valid password")
Package & Print
if.. else Statement (User Authentication)
13. VELOCITY
Mr. V. VEERANAN, M.Sc. Computer Science., Dip.in.Yoga.,
import matplotlib.pyplot as plt
u = float(input("Enter the initial velocity: "))
a = float(input("Enter the acceleration: "))
time_values = [i*0.5 for i in range(21)
velocity_values = [u + a*t for t in time_values]
distance_values_time = [u*t + 0.5*a*t**2 for t in time_values]
velocity_squared_values = [(u + a*t)**2 for t in time_values]
distance_values_velocity = [(v**2 - u**2)/(2*a) for v in velocity_squared_values]
plt.plot(time_values, velocity_values)
plt.title('Velocity vs. Time')
plt.xlabel('Time (s)')
plt.ylabel('Velocity (m/s)')
plt.show()
Package & Print
Range
Calculation
Label
Mr. V. VEERANAN, M.Sc. Computer Science., Dip.in.Yoga.,
plt.plot(time_values, distance_values_time)
plt.title('Distance vs. Time')
plt.xlabel('Time (s)')
plt.ylabel('Distance (m)')
plt.show()
plt.plot(velocity_squared_values, distance_values_velocity)
plt.title('Distance vs. Velocity')
plt.xlabel('Velocity Squared (m^2/s^2)')
plt.ylabel('Distance (m)')
plt.show()
Label
Label
13. VELOCITY
14. ROBOT
Mr. V. VEERANAN, M.Sc. Computer Science., Dip.in.Yoga.,
import math
def compute_distance(movements):
x, y = 0, 0
for move in movements:
direction, steps = move.split()
steps = int(steps)
if direction == 'UP':
y += steps
elif direction == 'DOWN':
y -= steps
elif direction == 'LEFT':
x -= steps
elif direction == 'RIGHT':
x += steps
distance = math.sqrt(x**2 + y**2)
return round(distance)
# Take input from the user
moves = []
while True:
move = input("Enter a movement (or 'done' to finish): ")
if move == 'done':
break
moves.append(move)
# Compute and print the distance
distance = compute_distance(moves)
print("The distance from the original point is:", distance)
15. TUPLES
Mr. V. VEERANAN, M.Sc. Computer Science., Dip.in.Yoga.,
def get_info():
name, age, height = input().split(',')
return name.strip(), int(age.strip()), int(height.strip())
n = int(input("Enter the number of tuples: "))
tuples = []
for i in range(n):
tuple = get_info()
tuples.append(tuple)
sorted_tuples = sorted(tuples, key=lambda x: (x[0], x[1], x[2]))
print("Sorted Tuples:")
for tuple in sorted_tuples:
print(", ".join(str(i) for i in tuple))
15. TUPLES
Mr. V. VEERANAN, M.Sc. Computer Science., Dip.in.Yoga.,
def get_info():
name, age, height = input().split(',')
return name.strip(), int(age.strip()), int(height.strip())
n = int(input("Enter the number of tuples: "))
tuples = []
for i in range(n):
tuple = get_info()
tuples.append(tuple)
sorted_tuples = sorted(tuples, key=lambda x: (x[0], x[1], x[2]))
print("Sorted Tuples:")
for tuple in sorted_tuples:
print(", ".join(str(i) for i in tuple))
15. TUPLES
Mr. V. VEERANAN, M.Sc. Computer Science., Dip.in.Yoga.,
def get_info():
name, age, height = input().split(',')
return name.strip(), int(age.strip()), int(height.strip())
n = int(input("Enter the number of tuples: "))
tuples = []
for i in range(n):
tuple = get_info()
tuples.append(tuple)
sorted_tuples = sorted(tuples, key=lambda x: (x[0], x[1], x[2]))
print("Sorted Tuples:")
for tuple in sorted_tuples:
print(", ".join(str(i) for i in tuple))

More Related Content

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

Exploring Canvas
Exploring CanvasExploring Canvas
Exploring Canvas
Kevin Hoyt
 
Vectors in Two and Three.pptx
Vectors in Two and Three.pptxVectors in Two and Three.pptx
Vectors in Two and Three.pptx
gayashani2
 
circ.db.dbcircleserver(1).py#!usrlocalbinpython3im.docx
circ.db.dbcircleserver(1).py#!usrlocalbinpython3im.docxcirc.db.dbcircleserver(1).py#!usrlocalbinpython3im.docx
circ.db.dbcircleserver(1).py#!usrlocalbinpython3im.docx
christinemaritza
 
engineeringmathematics-iv_unit-iv
engineeringmathematics-iv_unit-ivengineeringmathematics-iv_unit-iv
engineeringmathematics-iv_unit-iv
Kundan Kumar
 

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

밑바닥부터 시작하는 의료 AI
밑바닥부터 시작하는 의료 AI밑바닥부터 시작하는 의료 AI
밑바닥부터 시작하는 의료 AI
 
Assignment 5.2.pdf
Assignment 5.2.pdfAssignment 5.2.pdf
Assignment 5.2.pdf
 
8. Vectors data frames
8. Vectors data frames8. Vectors data frames
8. Vectors data frames
 
GROUP 3 PPT self learning activity pptx.
GROUP 3 PPT self learning activity pptx.GROUP 3 PPT self learning activity pptx.
GROUP 3 PPT self learning activity pptx.
 
MATHS LAB MANUAL 22mats11.pdf
MATHS LAB MANUAL 22mats11.pdfMATHS LAB MANUAL 22mats11.pdf
MATHS LAB MANUAL 22mats11.pdf
 
Ch4
Ch4Ch4
Ch4
 
Introduction to Neural Networks and Deep Learning from Scratch
Introduction to Neural Networks and Deep Learning from ScratchIntroduction to Neural Networks and Deep Learning from Scratch
Introduction to Neural Networks and Deep Learning from Scratch
 
matlab.docx
matlab.docxmatlab.docx
matlab.docx
 
Exploring Canvas
Exploring CanvasExploring Canvas
Exploring Canvas
 
Vectors in Two and Three.pptx
Vectors in Two and Three.pptxVectors in Two and Three.pptx
Vectors in Two and Three.pptx
 
Pre-Calculus - Vectors
Pre-Calculus - VectorsPre-Calculus - Vectors
Pre-Calculus - Vectors
 
Vectors data frames
Vectors data framesVectors data frames
Vectors data frames
 
Advanced Data Visualization Examples with R-Part II
Advanced Data Visualization Examples with R-Part IIAdvanced Data Visualization Examples with R-Part II
Advanced Data Visualization Examples with R-Part II
 
13 - 06 Feb - Dynamic Programming
13 - 06 Feb - Dynamic Programming13 - 06 Feb - Dynamic Programming
13 - 06 Feb - Dynamic Programming
 
Beyond Scala Lens
Beyond Scala LensBeyond Scala Lens
Beyond Scala Lens
 
circ.db.dbcircleserver(1).py#!usrlocalbinpython3im.docx
circ.db.dbcircleserver(1).py#!usrlocalbinpython3im.docxcirc.db.dbcircleserver(1).py#!usrlocalbinpython3im.docx
circ.db.dbcircleserver(1).py#!usrlocalbinpython3im.docx
 
6. R data structures
6. R data structures6. R data structures
6. R data structures
 
Presentation on calculus
Presentation on calculusPresentation on calculus
Presentation on calculus
 
Engineering Mathematics-IV_B.Tech_Semester-IV_Unit-IV
Engineering Mathematics-IV_B.Tech_Semester-IV_Unit-IVEngineering Mathematics-IV_B.Tech_Semester-IV_Unit-IV
Engineering Mathematics-IV_B.Tech_Semester-IV_Unit-IV
 
engineeringmathematics-iv_unit-iv
engineeringmathematics-iv_unit-ivengineeringmathematics-iv_unit-iv
engineeringmathematics-iv_unit-iv
 

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 1-8 MKU.pdf
Lab 3 Python Programming Lab 1-8 MKU.pdfLab 3 Python Programming Lab 1-8 MKU.pdf
Lab 3 Python Programming Lab 1-8 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

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)

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
 
Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
dusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningdusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learning
 
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
 
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
 
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...
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
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
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
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
 
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Ă...
 
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)
 

Lab 3 Python Programming Lab 8-15 MKU.pdf

  • 1. 9. 3D ANIMATION Mr. V. VEERANAN, M.Sc. Computer Science., Dip.in.Yoga., from vpython import * def show_curve(): curve(x=arange(100), y=arange(100)**0.5, color=color.red) def show_sphere(): ball = sphere(pos=vector(1,2,1), radius=0.5) def show_cone(): cone(textures=textures.stucco,axis=vector(-1,4,0),up=vector(1,2,2,)) def show_arrow(): arrow(pos=vector(-2,0,0),color=vector(1,0,1),axis=vector(1,2,2),up=vector(-1,5,2)) def show_rings(): ring(pos=vector(1, 1, 1), axis=vector(0, 1, 0), radius=0.5, thickness=0.1) def show_cylinder(): rod= cylinder(pos=vector(0, 2, 1), axis=vector(5, 0, 0), radius=1) Curve Sphere Cone Arrow Rings Cylinder
  • 2. 9. 3D ANIMATION Mr. V. VEERANAN, M.Sc. Computer Science., Dip.in.Yoga., def menu(): print('1. Curve') print('2. Sphere') print('3. Cone') print('4. Arrow') print('5. Rings') print('6. Cylinder') ch= 'y' while(ch=='y'): menu() choice = int(input('Enter choice..')) if(choice == 1): show_curve() elif(choice == 2): show_sphere() elif(choice == 3): show_cone() elif(choice == 4): show_arrow() elif(choice == 5): show_rings() elif(choice == 6): show_cylinder() else: print('Wrong choice') ch= input('Do you want to continue (y/n)...') Print Menu Curve Sphere Cone Arrow Rings Cylinder else Print
  • 3. 10. PULSE Vs HEIGHT Mr. V. VEERANAN, M.Sc. Computer Science., Dip.in.Yoga., import matplotlib.pyplot as plt n=int(input('enter the number of people:')) p=[] h=[] for i in range(n): p_i=int(input(f"enter pulse rate of person{i+1}:")) h_i=int(input(f"enter height no of person{i+1}:")) p.append(p_i) h.append(h_i) plt.scatter(h,p) plt.title("pulse rate vs height") plt.xlabel("height(cm)") plt.ylabel("pusle rate(bpm)") plt.show() if __name__=='__main__': main() Package & init p, h Declared Label & Value
  • 4. 11. MASS Vs TIME Mr. V. VEERANAN, M.Sc. Computer Science., Dip.in.Yoga., import matplotlib.pyplot as plt def calculate_mass(t): return 60/(t+2) time_values = [i*0.5 for i in range(21)] mass_values = [calculate_mass(t) for t in time_values] plt.plot(time_values, mass_values) plt.title('Graph of t vs. m') plt.xlabel('Time (hours)') plt.ylabel('Mass (grams)') plt.show() Package & Calculation Label & Values
  • 5. 12. PASSWORD Mr. V. VEERANAN, M.Sc. Computer Science., Dip.in.Yoga., import re p=input("Input your password:") x=True while x: if(len(p)<6 or len(p)>12): break elif not re.search("[a-z]",p): break elif not re.search("[0-9]",p): break elif not re.search("[A-Z]",p): break elif not re.search("[$#@]",p): break elif not re.search("s",p): break else: print("valid password") x=False break if x: print("Not a valid password") Package & Print if.. else Statement (User Authentication)
  • 6. 13. VELOCITY Mr. V. VEERANAN, M.Sc. Computer Science., Dip.in.Yoga., import matplotlib.pyplot as plt u = float(input("Enter the initial velocity: ")) a = float(input("Enter the acceleration: ")) time_values = [i*0.5 for i in range(21) velocity_values = [u + a*t for t in time_values] distance_values_time = [u*t + 0.5*a*t**2 for t in time_values] velocity_squared_values = [(u + a*t)**2 for t in time_values] distance_values_velocity = [(v**2 - u**2)/(2*a) for v in velocity_squared_values] plt.plot(time_values, velocity_values) plt.title('Velocity vs. Time') plt.xlabel('Time (s)') plt.ylabel('Velocity (m/s)') plt.show() Package & Print Range Calculation Label
  • 7. Mr. V. VEERANAN, M.Sc. Computer Science., Dip.in.Yoga., plt.plot(time_values, distance_values_time) plt.title('Distance vs. Time') plt.xlabel('Time (s)') plt.ylabel('Distance (m)') plt.show() plt.plot(velocity_squared_values, distance_values_velocity) plt.title('Distance vs. Velocity') plt.xlabel('Velocity Squared (m^2/s^2)') plt.ylabel('Distance (m)') plt.show() Label Label 13. VELOCITY
  • 8. 14. ROBOT Mr. V. VEERANAN, M.Sc. Computer Science., Dip.in.Yoga., import math def compute_distance(movements): x, y = 0, 0 for move in movements: direction, steps = move.split() steps = int(steps) if direction == 'UP': y += steps elif direction == 'DOWN': y -= steps elif direction == 'LEFT': x -= steps elif direction == 'RIGHT': x += steps distance = math.sqrt(x**2 + y**2) return round(distance) # Take input from the user moves = [] while True: move = input("Enter a movement (or 'done' to finish): ") if move == 'done': break moves.append(move) # Compute and print the distance distance = compute_distance(moves) print("The distance from the original point is:", distance)
  • 9. 15. TUPLES Mr. V. VEERANAN, M.Sc. Computer Science., Dip.in.Yoga., def get_info(): name, age, height = input().split(',') return name.strip(), int(age.strip()), int(height.strip()) n = int(input("Enter the number of tuples: ")) tuples = [] for i in range(n): tuple = get_info() tuples.append(tuple) sorted_tuples = sorted(tuples, key=lambda x: (x[0], x[1], x[2])) print("Sorted Tuples:") for tuple in sorted_tuples: print(", ".join(str(i) for i in tuple))
  • 10. 15. TUPLES Mr. V. VEERANAN, M.Sc. Computer Science., Dip.in.Yoga., def get_info(): name, age, height = input().split(',') return name.strip(), int(age.strip()), int(height.strip()) n = int(input("Enter the number of tuples: ")) tuples = [] for i in range(n): tuple = get_info() tuples.append(tuple) sorted_tuples = sorted(tuples, key=lambda x: (x[0], x[1], x[2])) print("Sorted Tuples:") for tuple in sorted_tuples: print(", ".join(str(i) for i in tuple))
  • 11. 15. TUPLES Mr. V. VEERANAN, M.Sc. Computer Science., Dip.in.Yoga., def get_info(): name, age, height = input().split(',') return name.strip(), int(age.strip()), int(height.strip()) n = int(input("Enter the number of tuples: ")) tuples = [] for i in range(n): tuple = get_info() tuples.append(tuple) sorted_tuples = sorted(tuples, key=lambda x: (x[0], x[1], x[2])) print("Sorted Tuples:") for tuple in sorted_tuples: print(", ".join(str(i) for i in tuple))