Python Revised
Python Revised
Step2: Get the input from the user “Enter the radius of the Circle”
Step 4: Print the output on the Screen Step 5: Stop the program
Step 4: Print a.
Step 7: Print a.
EXP2B:
EXP3A:
EXP 3B:
Step2: Get the input from the user "Input lengths of the triangle sides: "
Step 4: If it is not an Equilateral triangle, then check if X = Y or X = Z or Y = Z. If found tobe true, print “Isosceles Triangle”.
Step 5: If none of the above steps are satisfied, then print “Scalene Triangle”.
Step2: Get the input from the user asfor loop which ranges from the lower range to the upperrange.
Step 4: For each iteration it checks whether the i=3,6,9 if it is not the directly print x and itends up if i=3,6,9 it continue
to for loop and again it iterate.
EXP 5 A:
EXP 5 B:
Step 4: Print the numbers between the range (1,100) by using random.randint() function.
EXP 6b:
Step 4: for strs in string: used to iterate the each word in a list.
Step 5: divide the array into two parts to search an element in arraystep = step+1 mid = (start + end) // 2
Step 6: if element is found in mid return midif element == array[mid]: return mid
Step 7: if element is less than mid value it searches left sideif element < array[mid]: end = mid – 1
Step 8: else if element is greater than mid it searches right sideelse: start = mid + 1
Step 9: give the array and element to search of list it takes step 1 to 8.
employee={"kamani":20000,"praveena":30000,"Sri":45000,"madhu":31200}
Step 4: ask user to enter extra hours that the employee worked
Step 6: use for loop to search the employee name in the dictonaryfor i in employee:
Step 7: if name found in dictionary the gross salary for employee will be addedif name==i: grossalary=employee[name]
+gross
6 G:
7A:
Step 3: Use if loop and check whether number is greater than one or not.
Step 4: Use if loop take range above 2 and if (number % i) is equal to zero then the numberis not prime so print(number,
"is not a prime number")
Step 5: if (number % i) is not equal to zero then the number is prime soprint(number, "is a prime number")
7B:
Step 2: use def function def the(random): return random -> it takes random list to function
8B:
Step 3: start_time=process_time()
print(i, end="")
Step 5: stop_time=process_time()
10A:
Step 3: counter = 0
12:
Step 3: define init() function with object and propertiesdef _init_(self, height, width): self.height = height self.width =
width
Step 4: define reactangle_area def rectangle_area(self): return self.height*self.width //compute the formula and brings
area
Step 5: define a rectangle_perimeterdef rectangle_peri(self): return 2*self.height+self.width. // compute the formula
and bring perimeter
Step 6: give the values of height and width for two for rectangles to compute area and perimeter Rectangle_1=
Rectangle(24, 12) Rectangle_2 = Rectangle(12,25)
13:
Step 3: add the init() function to create a new objectdef _init_(self, model,year):
Step 5: use function to display and retun properties of object.def display(self): return(self.model, self.year)
Step 6: create a child class which will extend the properties of parent classclass price(Mobile): def _init_(self,
model,year,price):
Step 7: use super() function to inherit the properties of parent to child classsuper()._init_(model, year) self.price=price
Step 8: define a function used to return the properties of child class with parentdef pricing(self):
return(self.display(),self.price)