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
# resources: | |
# + https://www.tutorialspoint.com/python/python_gui_programming.htm | |
# + https://www.tutorialspoint.com/python/tk_radiobutton.htm | |
# + https://www.tutorialspoint.com/python/tk_entry.htm | |
from Tkinter import * | |
window = Tk() | |
# |
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
# prompt: | |
# Joe's Automotive performs the following routine maintenance services: | |
# + Oil change - $30.00 | |
# + Lube job - $20.00 | |
# + Radiator flush - $40.00 | |
# + Transmission flush - $100.00 | |
# + Inspection - $35.00 | |
# + Muffler replacement - $200.00 | |
# + Tire rotation - $20.00 | |
# Write a GUI program with check buttons that allow the user to select any or all of these services. |
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
# | |
# example using recursion, but output is reversed | |
# | |
def print_stars_desc(n): | |
print(str(n) + " stars: " + (n * "*")) | |
if n > 1: | |
print_stars_desc(n - 1) | |
print("") |
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
class Person: | |
def __init__(self, name, address, phone): | |
self._name = name | |
self._address = address | |
self._phone = phone | |
#boy = Person("Jake", "123 Main Street", "123-456-7890") | |
#print(boy._name, boy._address, boy._phone) | |
class Customer(Person): |
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
class Employee: | |
def __init__(self, name, number): | |
self._name = name | |
self._number = number | |
#employee = Employee("Mike", "123") | |
#print(employee._name, employee._number) | |
class Supervisor(Employee): | |
def __init__(self, name, number, annual_salary, bonus): |
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
# resources: | |
# https://docs.python.org/3/tutorial/classes.html | |
# https://www.tutorialspoint.com/python/python_classes_objects.htm | |
# https://learnpythonthehardway.org/book/ex40.html | |
class Pet: | |
# expects to be instantiated using a dictionary like ... | |
# pet = Pet({'name':'Kirby', 'type':'Dog', 'age':'really old'}) | |
def __init__(self, options): |
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
import os | |
import pickle # reference: https://wiki.python.org/moin/UsingPickle | |
# | |
# Write a program that keeps names and email addresses in a dictionary as key-value pairs. | |
# Each time the program starts, it should retrieve the dictionary from the file and unpickle it. | |
# | |
ADDRESS_BOOK_FILE_NAME = os.path.join(os.path.dirname(__file__), "address_book.p") |
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
from random import shuffle | |
state_capitals = { | |
"Alaska": "Juneau", | |
"Arizona": "Phoenix", | |
"Arkansas": "Little Rock", | |
"California": "Sacramento" | |
} # todo: get the rest from the internet |
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
courses = { | |
'CS101': {'room_number': '3004', 'instructor': 'Haynes', 'meeting_time': '8:00 am'}, | |
'CS102': {'room_number': '4501', 'instructor': 'Alvarado', 'meeting_time': '9:00 am'}, | |
'CS103': {'room_number': '6755', 'instructor': 'Rich', 'meeting_time': '10:00 am'}, | |
'NT110': {'room_number': '1244', 'instructor': 'Burke', 'meeting_time': '11:00 am'}, | |
'CM241': {'room_number': '1411', 'instructor': 'Lee', 'meeting_time': '1:00 pm'}, | |
} | |
course_number = input("Please input a course number. It should be one of: 'CS101', 'CS102', 'CS103', 'NT110', 'CM241'.") |