Welcome to my integers.

0 29
Avatar for Vernardo
2 years ago

Python3 Article #0.4

How this can really help us in terms of our daily lives knowing integers It is hard to explain in words but I hope you can get the idea in the code below.

For example you want to add 100 carrots plus 300 carrots and multiply them for 365 days.

#comment only  <---- this is a comment in python program. it starts with a hashtag sign.

carrot_1 = 100
carrot_2 = 300
days = 365
print(carrot_1 + carrot_2 * days)

#Using python interpreter it will be easier printing the statements they will produce the same results.

String formatting using what we have learned so far.

print('I have %s carrots in day one and %s carrots in day two I multiplied them by days of %s' % (carrot_1, carrot_2, days))

How can this really help us knowing integers in python?
For example you want to sum all of your earnings in read.cash on a yearly basis.

# I will only use four months in total.
january = 3
february = 5
march = 10
april = 3
total = january + february + march + april
print('I earned a total of %s dollars in read.cash' % total)
Sponsors of Vernardo
empty
empty
empty

if you want to display your earnings in bch that's totally fine but integers have no fraction it's a whole number positive or negative. If it has a decimal point it converts to a float.

print(type(1))
print(type(-1))
print(type(0.0233)
print(type(1.4))
print(type(-2.3))

If you add or multiply integer and float it will always return float unless you use the int() built in function to print the integer value of a number and that will be integer outcome.

add = 1 + 4.3
multiply = 1 * 4.3
print(add)
print(multiply)
type(add)
type(multiply)
int(add) #if you print(type(int(add))) this will return integer
int(multiply) #if you print(type(int(multipy))) this will return integer

And that's it for covering integer in this python tutorial I hope you understand the concept of integer and floating point in this article and if you have suggestion or question you would like to address you can do so in the comment section below.

Lead Image: Python Logo


My other social media where you can contact me for anything.

NoiseCash: noise.cash/@Vernardo

Telegram: PanPanHam

2
$ 0.00
Avatar for Vernardo
2 years ago

Comments