python code
python code
print("Reversed String:")
print(" ".join(string))
2. Create a class named MyCircle built by a radius and two methods which will
compute the area and the perimeter of a circle.
class MyCircle():
def radius(self,radius):
r = radius
def area(self,r):
area = 3.142*r*r
print("Area of the circle is: ",area)
def peri(self,r):
peri = 2*3.14*r
print("Perimeter of the circle is: ",peri)
c = Circle()
radius = int(input("Enter the radius of circle: "))
c.area(radius)
c.peri(radius)
3. Create a class Teacher with name, age, and salary attributes, where salary
must be a private attribute that cannot be accessed outside the class.
class Teacher():
def __init__(self, name, age, salary):
self.name = name
self.age = age
self.__salary = salary
def show_details(self):
print("Name:", self.name)
print("Age:", self.age)
print("Salary: ", self.__salary)
teacher = Teacher("", 45, 25000)
teacher.show_details()
import string, os
if not os.path.exists("letters"):
os.makedirs("letters")
for letter in string.ascii_uppercase:
with open(letter + ".txt", "w") as f:
f.writelines(letter)
7. Write to program to print buzz on multiple of input number and
take the length of the series as input too.
Example:
Inputed Series : 15
Number:5
1,2,3,4,buzz,6,7,8,9,buzz,11,12,13,14,buzz
11. Write a code to read content from one file and write it into
another file.