CodeSolved

Solved Programming Questions & Exercises

Rectangular cube class

Practice Easy 175/ Download 1403 Views

Write a class that receives the length, width and height of the rectangular cube and calculates its area and volume using different methods

13 Answers

This answer is only visible to premium members
This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error'
alert(msg) 
This answer is only visible to premium members
This answer is only visible to premium members

This answer is only visible to premium members

Subscription is currently unavailable.
This answer is only visible to premium members
This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error'
alert(msg) 
This answer is only visible to premium members
This answer is only visible to premium members

This answer is only visible to premium members

Subscription is currently unavailable.
This answer is only visible to premium members
This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error'
alert(msg) 
This answer is only visible to premium members
This answer is only visible to premium members

This answer is only visible to premium members

Subscription is currently unavailable.
class x:
    def __init__(self , tool , arz , artefa):
        self.tool=tool
        self.arz=arz
        self.artefa=artefa
    def masahat(self):
        print(self.tool*self.arz*6)
    def hajm(self):
        print(self.tool*self.arz*self.artefa)

while True:
    k=input("1.adame 2.laghv :")
    if k=="2":
        break
    elif k=="1":
        t=float(input("tool:"))
        a=float(input("arz:"))
        ar=float(input("artefa:"))
        m=x(t , a , ar)
        i=input("1.masahat 2.hajm :")
        if i=="1":
            m.masahat()
        elif i=="2":
            m.hajm()
        else:
            print("error")
    else:
        print("error")
Parsa.r Download Python
class maht:
    def __init__(self,a,b,c):
        self.a=a
        self.b=b
        self.c=c
    def math_h(self):
        return(f'The volume of a rectangular cube is equal to:{self.a*self.b*self.c}')
a1=int(input('enter length:'))
b1=int(input('enter width:'))
c1=int(input('enter height:'))
ob =maht(a1,b1,c1)
print(ob.math_h())
Omid.asadi Download Python
class MokabMostatil:
    def __init__(self,x,y,z):
        self.x=x
        self.y=y
        self.z=z
    def hajm(self):
        return self.x*self.y*self.z
    def masahat(self):
        return 2*self.x*self.y+2*self.x*self.z+2*self.y*self.z
Saeeda33 Download Python
a = float(input("your arz : )
b = float(input("your tol : )
c = float(input("your ertefa : )
x = a*b*c
m = (a*b*2) + (a*c*2) + (b*c*2)
print(f"masahat : {m}\n Hagm:{x}")

User 4865 Download Python
class RectangularPrism:
    def __init__(self, length, width, height):
        self.length = length
        self.width = width
        self.height = height

    def surface_area(self):
        """محاسبه مساحت سطح مکعب مستطیل"""
        return 2 * (self.length * self.width + self.length * self.height + self.width * self.height)

    def volume(self):
        """محاسبه حجم مکعب مستطیل"""
        return self.length * self.width * self.height

if __name__ == "__main__":
    # Get the length, width and height of the user
    while True:
        try:
            length = float(input("لطفاً طول مکعب مستطیل را وارد کنید: "))
            width = float(input("لطفاً عرض مکعب مستطیل را وارد کنید: "))
            height = float(input("لطفاً ارتفاع مکعب مستطیل را وارد کنید: "))
            break
        except ValueError:
            print("لطفاً یک عدد صحیح یا اعشاری وارد کنید.")

    # Creating an object from the Rectangularprism class
    prism = RectangularPrism(length, width, height)

    # Calculation and display area and volume
    print(f"مساحت سطح مکعب مستطیل: {prism.surface_area()} واحد مربع")
    print(f"حجم مکعب مستطیل: {prism.volume()} واحد مکعب")
Mma123 Download Python
class Mm:
    def __init__(self , ertefaa , arz , tool):
        self.ertefaa = ertefaa
        self.arz = arz
        self.tool = tool

    def hajm(self):
        return self.arz * self.tool * self.ertefaa
    
    def masahat(self):
        j = 2 * (self.ertefaa * self.arz + self.ertefaa * self.tool + self.arz * self.tool)
        return j
    
a = Mm(int(input("Ertefaa :")) , int(input("Arz :")) , int(input("Tool :")))

print("mashat :" ,a.masahat())
print()
print("hajm :" ,a.hajm())
Programmer Download Python
class mokeab:
    def __init__(self, tool, arz, ertefa):
        self.tool = (tool)
        self.arz = (arz)
        self.ertefa = (ertefa)
    def masahat(self):
        a = self.tool * self.arz
        return a * 6

    def hajm(self):
        return  self.tool * self.arz * self.ertefa

tool = int(input("enter tool:"))
arz = int(input("enter arz:"))
ertefa = int(input("enter ertefa:"))
e = mokeab(tool, arz, ertefa)
print('masahat:',e.masahat())
print('hajm:',e.hajm())
User 5141 Download Python
<< Previous page 1 2 Next page >>

Submit answer

Submitting answers is currently unavailable.

×
×
Close