Problem Solving and Python Programming (2021 Regulations Anna University,Chennai) LIST OF EXPERIMENTS: 1. Identification and solving of simple real life or scientific or technical problems, and developing flow charts for the same. (Electricity Billing, Retail shop billing, Sin series, weight of a motorbike, Weight of a steel bar, compute Electrical Current in Three Phase AC Circuit, etc.) 2. Python programming using simple statements and expressions (exchange the values of two variables, circulate the values of n variables, distance between two points). 3. Scientific problems using Conditionals and Iterative loops. (Number series, Number Patterns, pyramid pattern) 4. Implementing real-time/technical applications using Lists, Tuples. (Items present in library/ Components of a car/ Materials required for construction of a building –operations of list & tuples) 5. Implementing real-time/technical applications using Sets, Dictionaries. (Language, components o...
12. Developing a game activity using Pygame like bouncing ball, car race etc. SIMULATE BOUNCING BALL USING PYGAME To write a python program to simulate bouncing ball using pygame. PROGRAM/SOURCE CODE : import sys, pygame pygame.init() size = width, height = 800, 600 speed = [1, 1] background = 255, 255, 255 screen = pygame.display.set_mode(size) pygame.display.set_caption("Bouncing ball") ball = pygame.image.load("ball.png") ballrect = ball.get_rect() while 1: for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() ballrect = ballrect.move(speed) if ballrect.left < 0 or ballrect.right > width: ...
10. Implementing real-time/technical applications using Exception handling. (divide by zero error, voter’s age validity, student mark range validation) Program a=int(input("Entre a=")) b=int(input("Entre b=")) try: c = ((a+b) / (a-b)) #Raising Error if a==b: raise ZeroDivisionError #Handling of error except ZeroDivisionError: print ("a/b result in 0") else: print (c) Output Enter a=4 Enter b=4 a/b result in 0 Voter’s age validity a=int(input("Enter your age")) try: c = a #Raising Error if c<18: raise ValueError #Handling of error except ValueError: print ("not eligible for voting - enter above 18") else: print (c) Student ...
Comments
Post a Comment