Skip to content

Instantly share code, notes, and snippets.

View spaghettiSyntax's full-sized avatar
🏠
Working from home

spaghettiSyntax spaghettiSyntax

🏠
Working from home
View GitHub Profile
@spaghettiSyntax
spaghettiSyntax / februaryDays.py
Created December 6, 2017 06:27
Tony Gaddis Python: February Days
# 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'
@spaghettiSyntax
spaghettiSyntax / easter.py
Created December 6, 2017 06:29
Tony Gaddis Python: Easter
# 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
@spaghettiSyntax
spaghettiSyntax / zellersCongruence.py
Created December 6, 2017 06:57
Tony Gaddis Python: Zeller's Congruence
# 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): '))
@spaghettiSyntax
spaghettiSyntax / distanceConverter.py
Created December 6, 2017 07:01
Tony Gaddis Python: Distance Converter
# 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: '))
@spaghettiSyntax
spaghettiSyntax / lastName.py
Created December 6, 2017 07:04
Tony Gaddis Python: Last Name
# Asks for user's last name.
name = input('Last name: ')
print('Last name is:', name)
@spaghettiSyntax
spaghettiSyntax / tipTaxFoodCalc.py
Created December 6, 2017 07:06
Tony Gaddis Python: Tip, Tax, Food
# 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: '))
@spaghettiSyntax
spaghettiSyntax / average.py
Created December 6, 2017 07:09
Tony Gaddis Python: Average
# 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
@spaghettiSyntax
spaghettiSyntax / personInfo.py
Created December 6, 2017 07:10
Tony Gaddis Python: Personal Info
# 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: ')
@spaghettiSyntax
spaghettiSyntax / format.py
Created December 6, 2017 07:12
Tony Gaddis Python: Formatting
#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
@spaghettiSyntax
spaghettiSyntax / hotdogBuns.py
Created December 6, 2017 07:14
Tony Gaddis Python: Hot Dogs and Buns
#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,