Created
July 24, 2017 15:01
-
-
Save Ammly/6adbd34fc049afd1fb8063ce65ffd0bf to your computer and use it in GitHub Desktop.
Tech Academy python 101
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 100th birthday | |
def task1(): | |
name = str(input("Enter your name: ")) | |
age = int(input("Enter your age: ")) | |
yearsToHundred = (100 - age) + 2017 | |
print("Hello %s, you will turn hundred years old in %d." % (name, yearsToHundred)) | |
task1() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Check if entered number is Odd or Even | |
def task2(): | |
num = int(input("Enter Number to check: ")) | |
if num % 2 == 0: | |
print("%d is an even number." %num) | |
else: | |
print("%d is an odd number." %num) | |
task2() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# print nums less < 5 | |
def all_less_than_five(list = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]): | |
for i in list: | |
if i < 5: | |
print(i) | |
all_less_than_five() | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# palindrome or not | |
a = str(input("Enter to check palindrome:")) | |
def palindrome(): | |
#reverse the put. | |
b = a[::-1] | |
if a == b: | |
print("%s is palindrome." %a) | |
else: | |
print("%s is not palindrome." %a) | |
palindrome() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment