Posted 4 years ago
·
Author
Hello everyone. Python is one of widely used programming language and popular among every age groups (be it either school going or even a industry level professional). It's simplicity and compatibility with third party apps makes it easier to understand and build programs.
I am sharing some short codes that helped me as i am learning Python.
I am sharing some short codes that helped me as i am learning Python.
print("A simple age calculator")
name = input("whats your name?")
age = int(input('Enter your age: '))
days = age * 365
hours = days * 24
minutes = hours * 60
seconds = minutes * 60
print(name + ", you are alive for",days,"days,",hours,"hours,",minutes,"minutes",seconds,"seconds")
#Python program to print even Numbers between start to end. Where start and end are variables containing starting and ending number.
start = input("Enter the starting number")
end = input("Enter the ending number")
# iterating each number in list
for num in range(start, end):
# checking condition
if num % 2 = 0:
print(num)
num = num + 1
#Python program to print odd Numbers between start to end. Where start and end are variables containing starting and ending number.
start = input("Enter the starting number")
end = input("Enter the ending number")
# iterating each number in list
for num in range(start, end):
# checking condition
if num % 2 != 0:
print(num)
num = num + 1