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
# Create a student directory by allowing the user to enter all data. | |
def create_student_directory(): | |
all_students_by_onyen = {} | |
all_students_by_email = {} | |
all_students_by_name = {} | |
# Get as many students as the user wants to enter, | |
# storing each in “students” onyen as key. | |
stud_name = input('Enter student name (enter blank line to quit): ') | |
while stud_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
__author__ = 'David Gotz, gotz@unc.edu, Onyen = gotz' | |
import random | |
# Simulates a random card drawing. Returns a dictionary with suit and value | |
# keys. | |
def draw_card(): | |
suit = random.choice(["Spades", "Clubs", "Diamonds", "Hearts"]) | |
value = random.randint(1,13) |
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 random | |
MAX_NUMBER = 10 | |
def user_picks(): | |
user_numbers = set() | |
# Add six numbers to the set. | |
while len(user_numbers) < 6: |
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
# Playing Card class, represents a single playing card. | |
class PlayingCard: | |
def __init__(self, value, suit): | |
# Setup the instance variables. | |
self.value = value | |
self.suit = suit | |
self.face_up = False | |
def main(): |
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
# Playing Card class, represents a single playing card. | |
class PlayingCard: | |
def __init__(self, value, suit): | |
# Setup the instance variables. | |
self.value = value | |
self.suit = suit | |
self.face_up = False | |
def get_suit(self): | |
return self.suit |
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 random | |
# Playing Card class, represents a single playing card. | |
class PlayingCard: | |
def __init__(self, value, suit): | |
# Setup the instance variables. | |
if value == 1: | |
value = 'Ace' | |
elif value == 11: | |
value = 'Jack' |
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 random | |
# Playing Card class, represents a single playing card. | |
class PlayingCard: | |
# Value should be 1-13, with 1 for Ace, 11 for Jack, etc. | |
def __init__(self, value, suit): | |
# Setup the instance variables. | |
self.value = value | |
self.suit = suit |
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
# Get a list of names | |
def get_name_list(): | |
name_list = [] | |
name = input("Enter name #1 (or press enter to stop): ") | |
# Keep going until the empty string is returned by input. | |
while name != "": | |
# Append the most recent name and ask the user for the next name. | |
name_list.append(name.upper()) | |
name = input("Enter name #"+str(len(name_list)+1)+" (or press enter to stop): ") |
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 random | |
# Playing Card class, represents a single playing card. | |
class PlayingCard: | |
# Value should be 1-13, with 1 for Ace, 11 for Jack, etc. | |
def __init__(self, value, suit): | |
# Setup the instance variables. | |
self.value = value | |
self.suit = suit |
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 random | |
# Playing Card class, represents a single playing card. | |
class PlayingCard: | |
# Value should be 1-13, with 1 for Ace, 11 for Jack, etc. | |
def __init__(self, value, suit): | |
# Setup the instance variables. | |
self.value = value | |
self.suit = suit |