-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser-input.py
More file actions
40 lines (33 loc) · 982 Bytes
/
Copy pathuser-input.py
File metadata and controls
40 lines (33 loc) · 982 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#Ask for user input:
# print("Enter your name:")
# name = input()
# print(f"Hello {name}")
# print("whom do you love?")
# love = input()
# print(f"{love} loves you too")
#Add a message in front of the user input:
# name = input("Enter your name:")
# print(f"I am {name}")
#Multiple inputs:
# name = input("Enter your name:")
# print(f"Hello {name}")
# ques1 = input("Whom do you love:")
# ques2 = input("how much do you lover her:")
# ques3 = input("Does she love you:")
# print(f"Can you live without {ques1}, I love her {ques2} and {ques3} ?")
#To find the square root, the input has to be converted into a number:
# import math
# x = input("Enter a number:")
# #find the square root of the number:
# y = math.sqrt(float(x))
# print(f"The square root of {x} is {y}")
#Keep asking until you get a number:
y = True
while y == True:
x = input("Enter a number:")
try:
x = float(x)
y = False
except:
print("Wrong input, please try again.")
print("Thank you!")