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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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.

Expert Solution
Step 1

The program with the class are given below.

 

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Knowledge Booster
Mathematical functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education