Random Numbers

--Originally published at Monty Python and the Blogging Tale

So I decided to take another exercise from kencourses, and it was kind of tricky, but I could complete it. The challenge was creating a code that selected a number between 1 and 100, and the user had to guess the number, no matter the number of attempts. The code gives you clues as you keep trying:

numbers2

And here is the result:

random

Check out the code at my Github:

Kenxercises/Random.py

 


My new calculator

--Originally published at Newbie Programmer

giphy

Using python 3 as a calculator

I can use python 3 as a calculator using the interpreter of python, you can do the basic math functions.

numbers

The  integer numbers ( 23 , 45, 4) have type int , and the others numbers with a fractional part ( 2.5 , 4.34, 3.141592653….) have type float

The division (/) always returns a float number, to do a division to get a type int number you need to put // instead of / , and to calculate the remainder use the %.

paiton

In python is possible to use the ** operator to calculate powers, 2**2  is equal to write 2² (At a real calculator).

paitontri

You can use the equal sign = to assign a value to a variable, if you dont assing a variable, you cant use, and you accredit an error.

error65663545

In the interactive mode the last printed expression is assigned to the variable

taxes

And, you can round the number if you put the function round(AValuue,Numberofdecimals)

And now, a gif of a taco.

tacos