Skip to content

Instantly share code, notes, and snippets.

@ehedaoo
ehedaoo / Practice2b.py
Created April 30, 2017 18:07
Ask the user for two numbers: one number to check (call it num) and one number to divide by (check). If check divides evenly into num, tell that to the user. If not, print a different appropriate message.
# Ask the user for two numbers: one number to check (call it num) and one number to divide by (check).
# If check divides evenly into num, tell that to the user.
# If not, print a different appropriate message.
num = int(input("Enter a number: "))
check = int(input("Enter a number to divide by: "))
if num % check == 0:
print("Yusssss")
else:
@ehedaoo
ehedaoo / Practice2a.py
Created April 30, 2017 17:51
Ask the user for a number. Depending on whether the number is even or odd. print out an appropriate message to the user. If the number is a multiple of 4, print out a different message.
# Ask the user for a number. Depending on whether the number is even or odd.
# print out an appropriate message to the user.
# If the number is a multiple of 4, print out a different message.
num = int(input("Enter a number: "))
if num % 2 == 0:
if num % 4 == 0:
print("Your number is a multiple of 4")
else:
print("Your number is even")
@ehedaoo
ehedaoo / Practice2.py
Created April 30, 2017 17:49
Ask the user for a number. Depending on whether the number is even or odd. print out an appropriate message to the user.
# Ask the user for a number. Depending on whether the number is even or odd.
# print out an appropriate message to the user.
num = int(input("Enter a number: "))
if num % 2 == 0:
print("Your number is even")
else:
print("Your number is odd")
@ehedaoo
ehedaoo / Practice1a.py
Created April 30, 2017 13:44
Create a program that asks the user to enter their name and their age. Print out a message addressed to them that tells them the year that they will turn 100 years old. Add on to the previous program by asking the user for another number and printing out that many copies of the previous message.
# Create a program that asks the user to enter their name and their age. Print out a message addressed to them
# that tells them the year that they will turn 100 years old.
# Add on to the previous program by asking the user for another number
# and printing out that many copies of the previous message.
import datetime
def call1():
print("You will turn 100 in " + str(int(100-age) + int(year_now.year)))
@ehedaoo
ehedaoo / Practice1.py
Last active April 30, 2017 12:28
Create a program that asks the user to enter their name and their age. Print out a message addressed to them that tells them the year that they will turn 100 years old.
# Create a program that asks the user to enter their name and their age. Print out a message addressed to them
# that tells them the year that they will turn 100 years old.
#
import datetime
name = input("Hello! Please enter your name: ")
print("Hello " + name)
age = int(input("Enter your age: "))
year_now = datetime.datetime.now()
#print(year_now.year)
print("You will turn 100 in " + str(int(100-age) + int(year_now.year)))