CodeSolved

Solved Programming Questions & Exercises

Rectangular cube class

Practice Easy 175/ Download 2029 Views

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

18 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.
length= int(input("what's your number?"))
width= int(input("what's your number?"))
height= int(input("what's your number?"))
area= length*width
volume= length*width*height
print(f"area:{area}__volume:{volume}")
class RectangularCube:
    def __init__(self,width_rectangular,length_rectangular,height_rectangular):
        self.width_rectangular=width_rectangular
        self.length_rectangular=length_rectangular
        self.height_rectangular=height_rectangular
    def volume_rectangular(self):
        return self.width_rectangular*self.length_rectangular*self.height_rectangular
    def area_rectangular(self):
        return 2*(self.width_rectangular*self.length_rectangular+self.length_rectangular*self.height_rectangular+self.width_rectangular*self.height_rectangular)
while True:
    a=float(input("The width of the rectangular cube:\n"))
    b=float(input("Length of rectangular cube:\n"))
    c=float(input("Height of rectangular cube:\n"))
    if a<0 or b<0 or c<0:
        print("The input number is negative, please enter it again")
        continue
    else:
        break
u=RectangularCube(a,b,c)
while True:
    e=input("choose: 1.Volume  2.Area\n")
    if e=="1":
        print(f"Volume of a rectangular cube : {u.volume_rectangular()}")
        break
    elif e=="2":
        print(f"Area of rectangular cube : {u.area_rectangular()}")
        break
    else:
        print("The entered number is incorrect. Please try again")
        continue
Zaras Download Python
class Hajml_Masahat:
    def __init__(self,tool,arz,ertefah):
        self.tool = tool
        self.arz = arz
        self.ertefah = ertefah

    def masahat(self):
        s = self.tool * self.arz
        return f"masahat mostatil = {s}"

    def hajm(self):
        haj = self.tool * self.arz * self.ertefah
        return f"hajm mostatil = {haj}"

tool = int(input("enter your tool ="))
arz = int(input("enter your arz ="))
ertefah = int(input("enter your ertefah = "))
print(Hajml_Masahat(tool,arz,ertefah).hajm())
print(Hajml_Masahat(tool,arz,ertefah).masahat())
Sumy.amiri Download Python
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
<< Previous page 1 2 Next page >>

Submit answer

Submitting answers is currently unavailable.

×
×
Close