Quiz 3

--Originally published at Tomas Enciso

For the quiz in week 3 we had to write a program using functions, these functions had to get the square root of a number and the cube root of the same or a different number, any number is valid except for negative numbers, this you can evade by having an IF statement so that if the user decides to enter a negative number, the program won’t allow it.

Down here is the code that I wrote for this quiz:screen-shot-2017-01-31-at-4-22-48-pm

As you can see first of I had to import sqrt and pow from the math module, this is so I can use the square root and the cube root in my functions.

Heres the program running in the first one I used positive numbers and in the second image I used negative numbers so you could see the difference.

screen-shot-2017-01-31-at-4-27-41-pmscreen-shot-2017-01-31-at-4-28-04-pm


WSQ01

--Originally published at Tomas Enciso

Never in my life have a written a blog post so here it goes.

For the first post im gonna show a program I had to write that basically is a simple calculator and asks for your name, using inputs, outputs and some other fun stuff.

first of I started by printing “please enter your name” followed by an input that allows the user to enter his or her name. After that, this person will be greeted by hello (and the user’s name).

Using variables I was able to let the user choose two numbers and you would get the sum, subtraction, multiplication, the division with no decimals and the residue or the decimals of the previous division.

This is the code that I wrote:

print(“please enter your name”);
name = input(“”)
print(“Hello”,name)
x = int(input(“Please enter a number “))
y = int(input(“Now enter a different number “))
print(“If you sum these two numbers you get “,x + y)
print(“The subtraction of this two numbers is “,x – y)
print(“The multiplication of “, x, “and”, y, “is”,x * y)
print(“If you really want to know the division between”, x , “and”, y , “its”, x//y , “I guess…”) # no decimals included
print(“The remainder of this division is “, x % y, “im done, please make it stop”)

and here’s when you run it:

Tomass-MacBook-Pro-2:tecgda TomasEnciso$ python3 WSQ01.py

please enter your name

Tomas

Hello Tomas

Please enter a number 10

Now enter a different number 5

If you sum these two numbers you get  15

The subtraction of this two numbers is  5

The multiplication of  10 and 5 is 50

If you really want to know the division between 10 and 5 its 2 I guess…

The remainder of this division is  0 im done, please make it

Continue reading "WSQ01"