[source code] Python Programming Tutorial - 12 - Functions

0 Bucky Roberts · August 27, 2014
def beef():
    print("Dayum, functions are cool!")


def bitcoin_to_usd(btc):
    amount = btc * 527
    print(amount)


beef()
bitcoin_to_usd(3.85)
bitcoin_to_usd(1)
bitcoin_to_usd(13)

Post a Reply

Replies

Oldest  Newest  Rating
0 Erkin Öner · September 9, 2014
Thanks for Python tutorials Bucky!

However i wanted to develop tutorial example a bit.

First of all i wanted to take bitcoin amount from user, then wanted to call our funtion to do that. Here you can find my code in below,

def bitcoin_to_usd(btc):
    amount = btc * 527
    print(amount)

btc = input("Input your Bitcoins amount: ")

bitcoin_to_usd(btc)

it returns as what you write there. Such as if you type 2 it returns as 2222222222222222222222222222222222

I couldn't understand whats wrong with this code. Thank you for help.

Edit : We need to change this line as like this : btc = float(input("Input your Bitcoins amount: "))

Because in 3.x versions of Python input() function takes string information. With float or maybe int we can take numbers from user.
  • 1

Python

106,950 followers
About

This section is all about snakes! Just kidding.

Links
Moderators
Bucky Roberts Administrator