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
# February Days | |
# The goal of this exercise was to create a program | |
# that determined if it was a leap year or not. | |
print() | |
print(' Why leap day?', sep='') | |
print() | |
print(' "February 29 is a date that usually occurs every four years, \n' | |
'and is called leap day. This day is added to the calendar in \n' | |
'leap years as a corrective measure, because the Earth does not \n' |
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
# easter.py | |
# 10/26/17 | |
# A formula for computing Easter in the years 1900-2099, inclusive, as follows: | |
year = int(input("Input a year: ")) | |
a = year % 19 | |
b = year % 4 | |
c = year % 7 |
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
# zeller_congruence.py | |
# 10/28/17 | |
# Zeller's congruence is an algorithm | |
# developed by Christian Zeller to | |
# calculate the day of the week. | |
year = int(input('Enter year(e.g. 2015): ')) | |
month = int(input('Enter month(1-12): ')) | |
day = int(input('Enter day of the month(1-31): ')) |
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
# distance_converter.py | |
# 10/20/17 | |
# This program asks the user for input and does some basic unit conversions. | |
# First convert a distance given in miles, feet, and inches to just inches. | |
print('First, we will convert miles, feet, and inches to inches.') | |
miles = int(input('Input miles: ')) | |
feet = int(input('Input feet: ')) |
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
# Asks for user's last name. | |
name = input('Last name: ') | |
print('Last name is:', name) |
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
# Tip, Tax Food Calculator | |
# First Flowchart problem homework 1 | |
# We will use 18% as the tip rate | |
TIP_PERCENTAGE = 0.18 | |
# Currently the tax rate is 9% | |
TAX_PERCENTAGE = 0.09 | |
charge_for_food = float(input('Input charge for food: ')) |
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
# this program will compute | |
# the average of three values | |
# input by the user. | |
x = float(input('Number: ')) | |
y = float(input('Number: ')) | |
z = float(input('Number: ')) | |
average = (x + y + z) / 3 |
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
# this program asks the user for | |
# personal data and then prints | |
# it on the screen | |
name = input('Name: ') | |
city = input('City: ') | |
state = input('State: ') | |
zipcode = input('ZIP Code: ') | |
telephone_number = input('Telephone: ') | |
email_address = input('E-Mail: ') |
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
#To round a number when printing, we use the format function. Write the | |
#following code, run it to see what it prints. Then change the ‘.2f’ to | |
#‘.3f’ and see how that affects the results. | |
amount_due = 5000.0 | |
payment = amount_due / 12 | |
print('payment is', format(payment, '.2f')) | |
amount_due = 5000.0 | |
payment = amount_due / 12 |
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
#Write a Python program to convert a number of hot dogs to a number of | |
#packs of hot dogs and a number of packs of buns. You can assume that hot | |
#dogs come 10 to a pack and that buns come 8 to a pack. Prompt the user to | |
#enter a number of hotdogs, then compute and print the number of packages | |
#of hot dogs and buns that are needed to ensure you have enough hot dogs | |
#and buns,For example, if you need to serve 75 hot dogs and buns, you will | |
#need 8 packages of hot dogs and 10 packages of buns. To get the calculation | |
#of packages to come out to an integer, use math.ceil. For example, | |
#math.ceil(1.23)will give the value 2 as an integer. So if you need num_dogs, | |
#( say, 75)hot dogs and buns, that is math.ceil(num_dogs /10), i.e. 8, |