1write A Python Program To Generate Electricity Bill
1write A Python Program To Generate Electricity Bill
L = [5, 4, 2, 5, 6, 1]
res = []
for i in range(len(L)):
res.append((L[i], i))
print("List of Tuples")
print(res)
def recur_factorial(n):
if n == 1:
return n
else:
return n*recur_factorial(n-1)
num = 7
OUTPUT:
Output:
Enter the string :RAJESHAA
Total vowels are :3
else:
print("Sorry! This shape is not available")
# driver code
if __name__ == "__main__" :
# function calling
calculate_area(shape_name)
OUTPUT
Calculate Shape Area
Enter the name of shape whose area you want to find: rectangle
Enter rectangle's length: 10
Enter rectangle's breadth: 15
The area of rectangle is 150
# Python code
# To reverse words in a given string
# input string
string = "geeks quiz practice code"
# reversing words in a given string
s = string.split()[::-1]
l = []
for i in s:
# apending reversed words to l
l.append(i)
# printing reverse words
print(" ".join(l))
16 Simulate Bouncing Ball Using Pygame
import pygame
# initialize pygame
pygame.init()
# define colors
red = (255, 0, 0)
black = (0, 0, 0)
# define ball
ball_obj = pygame.draw.circle(
surface=screen, color=red, center=[100, 100], radius=40)
# define speed of ball
# speed = [X direction speed, Y direction speed]
speed = [1, 1]
# game loop
while True:
# event loop
for event in pygame.event.get():
# check if a user wants to exit the game or not
if event.type == pygame.QUIT:
exit()
# draw ball at new centers that are obtained after moving ball_obj
pygame.draw.circle(surface=screen, color=red,
center=ball_obj.center, radius=40)
# update screen
pygame.display.flip()
OUTPUT:
def Remove(duplicate):
final_list = []
for num in duplicate:
if num not in final_list:
final_list.append(num)
return final_list
# Driver Code
duplicate = [2, 4, 10, 20, 5, 2, 20, 4]
print(Remove(duplicate))