Hello, I'm looking for help on how to program with python. Very simple questions, shouldn't take too long to do.
These are the questions:
1. Input three numbers from the user, compute their sum and output the sum to the screen.
For example, to input a value from the keyboard to a variable x, you can use:
x = input (“Please input a number: “)
Import math
Def add (x1 + x2 + x3):
X = input (“Please input a number:”)
X1 = x
X2 = x
X3 = x
Return (x1+x2+x3)
Print(“The value of C = “, c)
2. Input a distance in kilometers from the user, convert it to miles, and output the miledistance.
X = input (“Please input a distance in kilometers:”)
Def convert (x1/x2 = x)
Return (x1/x2 = x)
Print (x + “miles”)
3. Ask the user for their pet’s name, and then tell them how adorable their pet is, saying “<name> is just adorable!”. Where <name> is the name input by theuser.
Print (“What is your pet’s name?)
X = Input (“X”)
Return (“X” is just adorable!”)
>>>name = input('What is your name?: ')
What is your name?: Charles
>>>print('Hello', name)
Hello Charles
4. Input a salary, and compute and output a basic tax on the salary assuch:
a. If the salary is in [0-50000[ , the tax is 15percent.
b. If the salary greater than or equal to 50000, the tax is 25percent.
X = Input (“Please input your salary so that we may calculate the tax:”)
X = (“0 < 50000”)*0.15
X = (“>50000”*0.25
Print (“Your tax is “X1”, “X2”)
5. Input two numbers from the user, swap the two numbers (using a third memory location), and output the numbers to the screen after swapping.
X = Input (“Please input two numbers:”)
def reverse(x):
y1 = x // 10
y2 = x % 10
return y2*10+y1
5. Input a GPA of a student in the range [0,4]. If the GPA isin:
a. [3-4] you say“Superb!”
b. [2-3[ you say“Good!”
c. [1-2[ you say“Hmm!”
d. [0-1[ you say “Nocomment!”
X = (“Please input a GPA from 0-4:”)
X1 = “3-4”
Print (“Superb!”)
X2 = “2-3”
Print (“Good!”)
X3 = “1-2”
Print (“Hmm!”)
X4 = “0-1”
Print (“No comment!”)
6. Input a number from the user and check whether the sum of the digits of the number is divisible by 7. You need to let the user know using an output message.
X = Input (“Please input a number that is divisible by 7:”)
Return (“X/7”)
Print (“The number is “X”, the number was divisible by 7”)
Print (“The number was not divisible by 7, please enter another number:”)
7. Input a phone number from the user in the form: (XXX)XXX-XXXX. If the number is not in this form, you need to give the user an error message, and ask them to try again (only once). Once the user inputs a valid number, you need to extract and print to the screen the area code.
X = Input (“Please input a number including the area code, in a form similar to this (XXX)XXX-XXXX:”)
Print (“The numbers included are not in the right form please try again:”)
Print (“The numbers are in the right form, thank you”)
8. Input someone’s first and last name as one string, and extract andoutput their last name to the screen.
X1 = “X”
X2 = “X”
Print (X1 = X2)
300fg to the first person that helps with all of the answers (and they're correct)