Python Codes (Part 5)
Some Codes for Practicing in Python
1. age=input("please enter your age?")
print(age)
age=int(age)
age>=20
-------------------------------------------------------------------------------------------------------------------
2. number=input("please enter a number")
number=int(number)
if number%2 == 0:
print(str(number) + "is even")
else:
print(str(number) + "is odd")
---------------------------------------------------------------------------------------------------------------------
3. n=input("Enter any value : ")
n=int(n)
i=1
sum=0
while i<=n:
sum=sum+i;
i+=1
print(sum)
---------------------------------------------------------------------------------------------------------------------
4. prompt=("\nPlease Enter the name of a city.")
prompt=prompt+("\nEnter 'quit' when you finished.")
while True:
city=input(prompt)
if city=='quit':
break;
else:
print("I'd love to go to "+city.title())
Comments
Post a Comment