Python - This is my code for a baby bitcoin program (question is below the code) balance=int(input("Enter the balance amount in USD: ")) n=int(input("Enter the value of 1 bitcoin in USD: ")) bcoins=0 while True: print("1. buy 0.5") print("2. buy 3000") print("3. sell 0.5") print("4. sell 3000") option = int(input("Enter choice:")) if option==1: bcoins=bcoins+0.5 balance=balance-0.5*n print("Balance after buying 0.5 bitcoin") print("The amount left in USD: ",balance) print("The number of bitcoins in the wallet: ",bcoins) print("The USD value of the bitcoins: ",bcoins*n) elif option==2: balance=balance-3000 bcoins=bcoins+3000/n print("Balance after buying bitcoin of worth 3000 USD") print("The amount left in USD: ",balance) print("The number of bitcoins in the wallet: ",bcoins) print("The USD value of the bitcoins: ",bcoins*n) elif option==3: bcoins=bcoins-0.5 balance=balance+0.5*n print("Balance after selling 0.5 bitcoin") print("The amount left in USD: ",balance) print("The number of bitcoins in the wallet: ",bcoins) print("The USD value of the bitcoins: ",bcoins*n) elif option==4: bcoins=bcoins-3000/n balance=balance+3000 print("Balance after selling bitcoin of worth 3000 USD") print("The amount left in USD: ",balance) print("The number of bitcoins in the wallet: ",bcoins) print("The USD value of the bitcoins: ",bcoins*n) else: break print("Final Balance") print("The amount left in USD: ",balance) print("The number of bitcoins in the wallet: ",bcoins) print("The USD value of the bitcoins: ",bcoins*n) Problem: Make a class wallet wallet which does the following 1) We need to store the ticker symbol for the coin 2) We need to store how many coins we currently have 3) We also need a “print” method in the class that will print the information out. So, this method will print out the ticker symbol (BTC) for the coin and the number of coins currently in the wallet. 4) We should also have an setter function to add coins to the wallet and a getter function to get the number of coins in the wallet.
Max Function
Statistical function is of many categories. One of them is a MAX function. The MAX function returns the largest value from the list of arguments passed to it. MAX function always ignores the empty cells when performing the calculation.
Power Function
A power function is a type of single-term function. Its definition states that it is a variable containing a base value raised to a constant value acting as an exponent. This variable may also have a coefficient. For instance, the area of a circle can be given as:
Python - This is my code for a baby bitcoin program (question is below the code)
balance=int(input("Enter the balance amount in USD: "))
n=int(input("Enter the value of 1 bitcoin in USD: "))
bcoins=0
while True:
print("1. buy 0.5")
print("2. buy 3000")
print("3. sell 0.5")
print("4. sell 3000")
option = int(input("Enter choice:"))
if option==1:
bcoins=bcoins+0.5
balance=balance-0.5*n
print("Balance after buying 0.5 bitcoin")
print("The amount left in USD: ",balance)
print("The number of bitcoins in the wallet: ",bcoins)
print("The USD value of the bitcoins: ",bcoins*n)
elif option==2:
balance=balance-3000
bcoins=bcoins+3000/n
print("Balance after buying bitcoin of worth 3000 USD")
print("The amount left in USD: ",balance)
print("The number of bitcoins in the wallet: ",bcoins)
print("The USD value of the bitcoins: ",bcoins*n)
elif option==3:
bcoins=bcoins-0.5
balance=balance+0.5*n
print("Balance after selling 0.5 bitcoin")
print("The amount left in USD: ",balance)
print("The number of bitcoins in the wallet: ",bcoins)
print("The USD value of the bitcoins: ",bcoins*n)
elif option==4:
bcoins=bcoins-3000/n
balance=balance+3000
print("Balance after selling bitcoin of worth 3000 USD")
print("The amount left in USD: ",balance)
print("The number of bitcoins in the wallet: ",bcoins)
print("The USD value of the bitcoins: ",bcoins*n)
else:
break
print("Final Balance")
print("The amount left in USD: ",balance)
print("The number of bitcoins in the wallet: ",bcoins)
print("The USD value of the bitcoins: ",bcoins*n)
Problem: Make a class wallet wallet which does the following
1) We need to store the ticker symbol for the coin 2) We need to store how many coins we currently have 3) We also need a “print” method in the class that will print the information out. So, this method will print out the ticker symbol (BTC) for the coin and the number of coins currently in the wallet. 4) We should also have an setter function to add coins to the wallet and a getter function to get the number of coins in the wallet.
The program with the class are given below.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 3 images