Answers for "how to find error in python code"

0

how to find error in python code

class Dogs:
#Constructor method that creates an instance of a dog
 #@param dname, the name of the dog
 #@param dbreed, the breed of the dog
 #@param dsize, the size of the dog
 def __init__(self, dName = "One", dBreed = "Sheppard", dSize = "Large"):
     self.name = dName
     self.breed = dBreed;
     self.size = dSize;
 #method jump makes the dog jump specified number of times
 #@param number which specifies the number of times the dog would jump
 def jump(self, number =1):
     for i in range(1,number+1):
         print("Jumps " , i , " times.")
     print()
 #method roll makes the dog roll specified number of times
 #@param number which specifies the number of times the dog would roll
 def roll(self,number):
     for i in range(1,number+1):
         print("Rolls " , i , " times.")
     print()
 #method pushcart makes the dog push the cart
 #in a specified direction for specified number of times
 #@param direction which specifies the direction in which the cart would be pushed
 #@param number which specifies the number of times the dog would push the cart
 def pushCart(self, direction, number):
     for i in range(1,number+1):
         print("Pushes " ,direction , " " , i , " times.")
     print()
 
 #method jumpHoop makes the dog jump hoops
 #@param number which specifies the number of times the dog would jumps hoops
 def jumpHoop(self,number):
     for i in range(1,number+1):
         print("Jumps Hoop " , i , " times.")
     print()
 #method printInfo prints the information; the name, breed and size of the object
 def printInfo(self):
     print("Name:",self.name)
     print("Breed:",self.breed)
     print("Size:",self.size)
     print()
#define the main method that tests the class definition
def main():
 #Creates four instances of dogs:
 #Kia, Tinky, Otto and Misty
     dog1 = Dog("Kia","Aidi", "Medium")
     dog2 = Dog("Tinky","Eskimo", "Small")
     dog3 = Dog("Otto","Akita", "Small")
     dog4 = Dog("Misty","Beagle", "Small")
     dog1.printInfo()
     dog1.jump(5)
     dog2.printInfo()
     dog2.roll(2)
     dog3.printInfo()
     dog3.pushCart("forward", 4)
     dog4.printInfo()
     dog4.jumpHoop(2)
main()
Posted by: Guest on July-09-2021
0

find the error python

print ("Welcome to the vending machine, type a product code: 1001 or 1002 ")
product_code = int(input())
KitKat_price = 2
doritos_price = 2.5
if (product_code == 1001):
  print("You have selected" , + (product_code))
  print("The price of the Kit Kat is 2$. Insert the neccesary coins")
  customer_money
  customer_money = int(input())
  if customer_money == KitKat_price:
    print("You have inserted 2$, KitKat is dispensing "
  if customer_money > KitKat_price:
    print("You have insterted more than 2$")
  if customer_money < KitKat_price:
    print("You have not inserted enough coins, instert more coins to get the KitKat")
if (product_code == 1002): 
  print("You have selected", + (product_code))
  print("The price of the doritos is 2.5$. Insert the neccesary coins:")
  customer_money = float(input())
  if customer_money > doritos_price:
    print("You have inserted more than 2.5$")
  if customer_money < doritos_price:
    print("You have not insterted enough coins, insert more coins to get the doritos")
  if customer_money == doritos_price:
    print("You have inserted 2$")
    print("Doritos is dispensing")
else:
  print("You have not selected any product code")
Posted by: Guest on May-03-2021

Code answers related to "how to find error in python code"

Python Answers by Framework

Browse Popular Code Answers by Language