diff --git a/github_for_beginners/github.py b/github_for_beginners/github.py new file mode 100644 index 0000000..e69de29 diff --git a/lab_assignments/adventure_fun_time.py/__init__.py b/lab_assignments/adventure_fun_time.py/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/lab_assignments/adventure_fun_time.py/actions.py b/lab_assignments/adventure_fun_time.py/actions.py new file mode 100644 index 0000000..4c36a52 --- /dev/null +++ b/lab_assignments/adventure_fun_time.py/actions.py @@ -0,0 +1,37 @@ +import player + + +class Action(): + def __init__(self, method, name, hotkey, **kwargs): + self.method = method + self.hotkey = hotkey + self.name = name + self.kwargs = kwargs + + def __str__(self): + return"{}: {}".format(self.hotkey, self.name) + +class Up(Action): + def __init__(self): + super().__init__(method = Player.up, name = 'Move Up', hotkey = 'w') + +class Down(Action): + def __init__(self): + super().__init__(method = Player.down, name = 'Move Down', hotkey = 's') + +class Left(Action): + def __init__(self): + super().__init__(method = Player.left, name = 'Move Left', hotkey = 'a') + +class Right(Action): + def __init__(self): + super().__init__(method = Player.move_right, name = 'Move Right', hotkey = 'd') + +class ViewInventory(Action): + """Prints the player's inventory""" + def __init__(self): + super().__init(method = Player.print_inventory, name ='view inventory', hotkey='i') + +class Attack(Action): + def __init__(self, Creature): + super().__init__(method = Player.attack, name ='Attack', hotkey='a', creature = Creature) diff --git a/lab_assignments/adventure_fun_time.py/credit_card.py b/lab_assignments/adventure_fun_time.py/credit_card.py new file mode 100644 index 0000000..8ced474 --- /dev/null +++ b/lab_assignments/adventure_fun_time.py/credit_card.py @@ -0,0 +1,4 @@ +print('What is your credit card number? ') +card_number = list(input()) + +print(card_number) \ No newline at end of file diff --git a/lab_assignments/adventure_fun_time.py/game.py b/lab_assignments/adventure_fun_time.py/game.py new file mode 100644 index 0000000..e5ce221 --- /dev/null +++ b/lab_assignments/adventure_fun_time.py/game.py @@ -0,0 +1,23 @@ +import world +from player import Player + +def play(): + world.load_tiles() + player = Player() + while player.is_alive() and not player.victory: + room = world.tile_exists(player.location_x, player.location_y) + room.modify_player(player) +#Check again since the room could have change + if player.is_alive() and not player.victory: + print("Choose an action: \n") + available_actions = room.available_actions() + for action in available_actions = room.available_actions(): + print(action) + action_input = input('Action: ').lower() + for action in available_actions: + if action_input == action.hotkey: + player.do_action(action, **action.kwargs) + break + +if __name__ = '__main__': + play() \ No newline at end of file diff --git a/lab_assignments/adventure_fun_time.py/game_parts.py b/lab_assignments/adventure_fun_time.py/game_parts.py new file mode 100644 index 0000000..3784eb6 --- /dev/null +++ b/lab_assignments/adventure_fun_time.py/game_parts.py @@ -0,0 +1,78 @@ +import random + +class Item: + def __init__(self, name, description): + self.name = name + self.description = description + + def __str__(self): + return "{}\n=====\n{}\n".format(self.name, self.description) + +class Weapon(Item): + def __init__(name, atk, loc): + self.dmg = dmg + super().__init(name, description, value) + + def __str__(self): + return "{}\n=====\nDamage: {}".format(self.name, self.description, self.damage) +class r_sword(Weapon): + def __init(self): + super().__init__( + name = 'Ruby Sword' + description = "A sword that shines with a red glow." + dmg = 10) + +class c_sword(Weapon): + def __init__(self): + super().__init__( + name = 'Cobalt Sword' + description = "A sword that shines with a blue glow." + dmg = 20) + +class d_sword(Weapon): + def __init__(self): + super().__init__( + name = 'Diamond Sword' + description = "A sword that shines with a white glow." + dmg = 30 + ) +class Potion(Item): + def __init__(health_plus): + self.health_plus = health_plus + super()__init__( + name = 'Health Potion' + description = 'Increase health points by 10 pts' + ) + +class Creature: + def __init__(self, name, hp, atk): + self.name = name + self.healthpoints = hp + self.attack = atk + + def is_alive(self): + return self.healthpoints > 0 + +class red_dragon(Creature): + def __init__(self): + super().__init__( + name = "Red Dragon" + hp = 100 + atk = 20 + ) + +class Blue_dragon(Creature): + def __init__(self): + super().__init__( + name = "Blue Dragon" + hp = 125 + atk = 30 + ) + +class Black_dragon(Creature): + def __init__(self): + super().__init__( + name = "Black Dragon" + hp = 150 + atk = 50 + ) \ No newline at end of file diff --git a/lab_assignments/adventure_fun_time.py/player.py b/lab_assignments/adventure_fun_time.py/player.py new file mode 100644 index 0000000..b1e0343 --- /dev/null +++ b/lab_assignments/adventure_fun_time.py/player.py @@ -0,0 +1,51 @@ +import game_parts + +class Player(): + def __init__(self): + self.inventory = [Item.r_sword(), Item.Potion()] + self.hp = 100 + self.location_x, self.location_y = world.starting_position + self.victory = False + + def is_alive(self): + return self.hp > 0 + + def print_inventory(self): + for item in self.inventory: + print(item, '\n') + def move(self, dx, dy): + self.location_x += dx + self.location_y = dy + print(world.tile_exists(self.location_x, self.location_y).intro_text()) + + def move_up(self): + self.move(dx=0, dy=-1) + + def move_down(self): + self.move(dx=0, dy=-1) + + def move_left(self): + self.move(dx=1, dy=0) + + def move_right(self): + self.move(dx=-1, dy=0) + + def attack(self, enemy): + best_weapon = None + max_dmg = 0 + for i in self.inventory: + if isinstance(i, Item.Weapon): + if i.damage > max_dmg: + best_weapon = i + print("You use {} against {}!".format(best_weapon.name, enemy.name)) + enemy.hp -= best_weapon.damage + if not enemy.is_alive(): + print("you Killed {}!".format(enemy.name)) + + def do_action(self, action, **kwargs): + action_method = getattr(self, action.method.__name__) + if action_method: + action_method(**kwargs) + + else: + print("{}HP is {}.".format(enemy.name, enemy.hp)) diff --git a/lab_assignments/adventure_fun_time.py/tiles.py b/lab_assignments/adventure_fun_time.py/tiles.py new file mode 100644 index 0000000..486f139 --- /dev/null +++ b/lab_assignments/adventure_fun_time.py/tiles.py @@ -0,0 +1,164 @@ +import Weapon, Item, Creature, World + +class MapTiles: + def __init__(self, x, y): + self.x = x + self.y = y + + def intro_text(self): + raise NotImplementedError() + + def modify_player(self, player): + raise NotImplementedError() + + def adjacent_moves(self): + if world.tile_exists(self.x + 1, self.y): + moves.append(actions.left()) + + if world.tile_exists(self.x - 1, self.y): + moves.append(actions.right()) + + if world.tile_exists(self.x, self.y - 1): + moves.append(actions.up()) + + if world.tile_exists(self.x, self.y +1): + moves.append(actions.down()) + + return moves + def available_actions(self): + """Returns all of the Available actions in this room + """ + moves = self.adjacent_moves() + moves.append(action.ViewInventory()) + return moves + +class StartRoom(MapTiles): + def intro_text(self): + """ + {}, are you awake now? + We were attacked by a {} and now the town is on fire. + While we put out the flames you've got to find that + wretched creature and destroy him! + + """.formate(player, creature) + + def modify_player(self, player): + #Room has no action on player + pass + +class HideItem(MapTile): + def __init__(self, X, y, item): + self.item = item + super().__init__(x, y) + + def add_item(self, player): + player.inventory.append(self.item) + + def modify_player(self, player): + self.add_item(player) + +class HideCreature(MapTile): + def _init__(self, x, y, enemy): + self.enemy = enemy + super().__init__(x, y) + + def modify_player(self, the_player): + if self.enemy.is_alive(): + the_player.hp = the_player.hp - self.enemy.damage + print("{} does {} damage.\nYou have {} HP remaining.".format(creature.name, self.enemy.damage, the_player.hp)) + + def available_actions(self): + if self.enemy.is_alive(): + the_player.hp = the_player.hp - self.enemy.damage + return [actions.Flee(tile=self), actions.Attack(creature=self.creature)] + else: + return self.adjacent_moves() + +class HideRdDragon(HideCreature): + def __init__(self, x, y): + super().__init__(x, y, creatures.red_dragon()) + + def intro_text(self): + if self.creature.is_alive(): + return """ + You find yourself face to face with a Red Dragon. It's belly warm with fire + he lets out a deafening screech. + """ + else: + return """ + The carcaus is still warm from your previous battle. + """ + +class HideBlDragon(HideCreature): + def __init__(self, x, y): + super().__init__(x, y, Creature.blue_dragon()) + + def intro_text(self): + if self.creature.is_alive(): + return """ + You find yourself face to face with a Blue Dragon. She doesn't like to be disturbed. + The dragon lunges at you. + """ + else: + return """ + The carcaus is still warm from your previous battle. + """ + +class HideBlkDragon(HideCreature): + def __init__(self, x, y): + super().__init__(x, y, Creature.black_dragon()) + + def intro_text(self): + if self.creature.is_alive(): + return """ + You find yourself face to face with a Black Dragon. + He lays in a valcano that seems to be the fuel for his rage. + """ + else: + return """ + The carcaus is still warm from your previous battle. + """ +class HidePotion(HideItem): + def __init__(self, x, y): + super().__init__(x, y, Item.Potion()) + + def intro_text(self): + return """ + You have found a potion, it will bring you back to life. + """ + +class HideRdSword(HideItem): + def __init__(self, x, y): + super().__init__(x, y, Item.r_sword()) + + def intro_text(self): + return """ + You have found a sword that shines Red. + """ + +class HideCSword(HideItem): + def __init__(self, x, y): + super().__init__(x, y, Item.c_sword()) + + def intro_text(self): + return """ + You have found a sword that shines blue. + """ + +class HideDSword(HideItem): + def __init__(self, x, y): + super().__init__(x, y, Item.d_sword()) + + def intro_text(self): + return """ + You have found a sword that shines with a white light. + """ + +class Victory(MapTiles): + def intro_text(self): + return """ + You have defeated the great dragon and saved our land! + """ + + def modify_player(self, player): + player.victory = True \ No newline at end of file diff --git a/lab_assignments/blackjack/__pycache__/cards.cpython-36.pyc b/lab_assignments/blackjack/__pycache__/cards.cpython-36.pyc new file mode 100644 index 0000000..8777a56 Binary files /dev/null and b/lab_assignments/blackjack/__pycache__/cards.cpython-36.pyc differ diff --git a/lab_assignments/blackjack/blackjack.py b/lab_assignments/blackjack/blackjack.py new file mode 100644 index 0000000..67ec05e --- /dev/null +++ b/lab_assignments/blackjack/blackjack.py @@ -0,0 +1,22 @@ +#Main game file +print('Would you like to start a new game of Black Jack?: Y or N') +start = input().lower() + +yes = 'y' +no = 'n' + +print('player one score: \n' +'hand: \n' +'cards played: \n') + +print('Dealer one score: \n' +'hand: \n' #have the number of cards but remove the value +'cards played: \n') + +#Start a new game + +#Score a hand + +#Bust if the score is over 21 + +#Bust if the user draws more the 5 cards \ No newline at end of file diff --git a/lab_assignments/blackjack/blackjack_table.py b/lab_assignments/blackjack/blackjack_table.py new file mode 100644 index 0000000..a58ff54 --- /dev/null +++ b/lab_assignments/blackjack/blackjack_table.py @@ -0,0 +1,59 @@ +import random + +class Card: + def __init__(self, suit, value): + self.suit = suit + self.value = value + + def show(self): + print('{} of {}'.format(self.suit, self.value)) + +class Deck: + def __init__(self): + self.cards = [] + self.build() + + def build(self): + for s in ['spades', 'clubs', 'diamonds', 'hearts']: + for v in range(1, 14): + self.cards.append(Card(s, v)) + + def show(self): + for c in self.cards: + c.show() + + def shuffle(self): + for i in range(len(self.cards)-1, 0, -1): + r = random.randint(0, i) + self.cards[i], self.cards[r] = self.cards[r], self.cards[i] + + def draw(self): + return self.cards.pop() + + +class Player: + def __init__(self, name): + self.name = name + self.hand = [] + + def draw(self, deck): + self.hand.append(deck.draw()) + return self + + def showhand(self): + for card in self.hand: + card.show() + + def discard(self): + return self.hand.pop() + +deck_1 = Deck() +deck_1.shuffle() + +player_1 = Player("Player 1") +player_1.draw(deck_1).draw(deck_1) +player_1.showhand() + +dealer_1 = Player("Dealer 1") +dealer_1.draw(deck_1).draw(deck_1) +dealer_1.showhand() \ No newline at end of file diff --git a/lab_assignments/blackjack/cards.py b/lab_assignments/blackjack/cards.py new file mode 100644 index 0000000..376fac1 --- /dev/null +++ b/lab_assignments/blackjack/cards.py @@ -0,0 +1,85 @@ +# #give cards suit and rank +# import random + +# card_values = { +# 'Ace': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, '10': 10, 'jack': 10, 'queen': 10, 'king': 10 +# } + +# suits = ['Hearts', 'Diamonds', 'Spades', 'Clubs'] + +# class Card: +# def __init__(self, suit, rank, value): +# self.suit = suit +# self.rank = rank + +# def __str__(self): +# return '{} of {}'.format(self.rank, self.suit) + +# def __repr__(self): +# return '{} of {}'.format(self.rank[0], self.suit) + +# class Deck: +# def __init__(self, suit, rank, value): +# self.cards = [Card(suit, rank) for s in suit for r in rank] +# self.shuffle() + +# def __str__(self): +# deck_cards = '' +# for cards in self.cards: +# deck_cards = deck_cards + str(card) + '' +# return deck_cards + +# def shuffle(self): +# random.shuffle(self.cards) + +# def deal_card(self): +# card = self.cards.pop(0) +# return cards + +# class Hand: +# def __init__(self): +# self.hand = [] + +# def add_card(self, card): +# self.hand.append(card) +# return self.hand + +# def get_value(self): +# aces = 0 +# value = 0 +# for card in self.hand: +# if Card.is_ace(): +# aces =+ 1 +# value += card.point +# while (value > 21) and aces: +# value -= 10 +# aces -= 1 +# return value + +import random + +card_values = { + 'Ace': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, '10': 10, 'jack': 10, 'queen': 10, 'king': 10 + } + +suits = ['Hearts', 'Diamonds', 'Spades', 'Clubs'] + +class Card: + def __init__(self, suit, rank, value): + self.suit = suit + self.rank = rank + self.value = value + + def __str__(self): + return '{} of {}'.format(self.rank, self.suit) + + def __repr__(self): + return '{} of {}'.format(self.rank[0], self.suit[0]) + +deck = [] + +for s in suits: + for rank, value in card_values.items(): + deck.append(Card(s, rank, value)) +random.shuffle(deck) + return deck \ No newline at end of file diff --git a/lab_assignments/blackjack/deck.py b/lab_assignments/blackjack/deck.py new file mode 100644 index 0000000..8bb3da1 --- /dev/null +++ b/lab_assignments/blackjack/deck.py @@ -0,0 +1,14 @@ +import cards +import random + +print(Card()) + +class Deck(Card): + deck = [] + for s in suits: + for rank, value in card_values.items(): + deck.append(Card(s, rank, value)) + random.shuffle(deck) + return deck + +print(Deck()) \ No newline at end of file diff --git a/lab_assignments/blackjack/hand.py b/lab_assignments/blackjack/hand.py new file mode 100644 index 0000000..e69de29 diff --git a/lab_assignments/cars/__pycache__/cars.cpython-36.pyc b/lab_assignments/cars/__pycache__/cars.cpython-36.pyc new file mode 100644 index 0000000..a8fe65a Binary files /dev/null and b/lab_assignments/cars/__pycache__/cars.cpython-36.pyc differ diff --git a/lab_assignments/cars/adventure_fun_time.py/__init__.py b/lab_assignments/cars/adventure_fun_time.py/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/lab_assignments/cars/adventure_fun_time.py/actions.py b/lab_assignments/cars/adventure_fun_time.py/actions.py new file mode 100644 index 0000000..4c36a52 --- /dev/null +++ b/lab_assignments/cars/adventure_fun_time.py/actions.py @@ -0,0 +1,37 @@ +import player + + +class Action(): + def __init__(self, method, name, hotkey, **kwargs): + self.method = method + self.hotkey = hotkey + self.name = name + self.kwargs = kwargs + + def __str__(self): + return"{}: {}".format(self.hotkey, self.name) + +class Up(Action): + def __init__(self): + super().__init__(method = Player.up, name = 'Move Up', hotkey = 'w') + +class Down(Action): + def __init__(self): + super().__init__(method = Player.down, name = 'Move Down', hotkey = 's') + +class Left(Action): + def __init__(self): + super().__init__(method = Player.left, name = 'Move Left', hotkey = 'a') + +class Right(Action): + def __init__(self): + super().__init__(method = Player.move_right, name = 'Move Right', hotkey = 'd') + +class ViewInventory(Action): + """Prints the player's inventory""" + def __init__(self): + super().__init(method = Player.print_inventory, name ='view inventory', hotkey='i') + +class Attack(Action): + def __init__(self, Creature): + super().__init__(method = Player.attack, name ='Attack', hotkey='a', creature = Creature) diff --git a/lab_assignments/cars/adventure_fun_time.py/credit_card.py b/lab_assignments/cars/adventure_fun_time.py/credit_card.py new file mode 100644 index 0000000..8ced474 --- /dev/null +++ b/lab_assignments/cars/adventure_fun_time.py/credit_card.py @@ -0,0 +1,4 @@ +print('What is your credit card number? ') +card_number = list(input()) + +print(card_number) \ No newline at end of file diff --git a/lab_assignments/cars/adventure_fun_time.py/game.py b/lab_assignments/cars/adventure_fun_time.py/game.py new file mode 100644 index 0000000..e5ce221 --- /dev/null +++ b/lab_assignments/cars/adventure_fun_time.py/game.py @@ -0,0 +1,23 @@ +import world +from player import Player + +def play(): + world.load_tiles() + player = Player() + while player.is_alive() and not player.victory: + room = world.tile_exists(player.location_x, player.location_y) + room.modify_player(player) +#Check again since the room could have change + if player.is_alive() and not player.victory: + print("Choose an action: \n") + available_actions = room.available_actions() + for action in available_actions = room.available_actions(): + print(action) + action_input = input('Action: ').lower() + for action in available_actions: + if action_input == action.hotkey: + player.do_action(action, **action.kwargs) + break + +if __name__ = '__main__': + play() \ No newline at end of file diff --git a/lab_assignments/cars/adventure_fun_time.py/game_parts.py b/lab_assignments/cars/adventure_fun_time.py/game_parts.py new file mode 100644 index 0000000..3784eb6 --- /dev/null +++ b/lab_assignments/cars/adventure_fun_time.py/game_parts.py @@ -0,0 +1,78 @@ +import random + +class Item: + def __init__(self, name, description): + self.name = name + self.description = description + + def __str__(self): + return "{}\n=====\n{}\n".format(self.name, self.description) + +class Weapon(Item): + def __init__(name, atk, loc): + self.dmg = dmg + super().__init(name, description, value) + + def __str__(self): + return "{}\n=====\nDamage: {}".format(self.name, self.description, self.damage) +class r_sword(Weapon): + def __init(self): + super().__init__( + name = 'Ruby Sword' + description = "A sword that shines with a red glow." + dmg = 10) + +class c_sword(Weapon): + def __init__(self): + super().__init__( + name = 'Cobalt Sword' + description = "A sword that shines with a blue glow." + dmg = 20) + +class d_sword(Weapon): + def __init__(self): + super().__init__( + name = 'Diamond Sword' + description = "A sword that shines with a white glow." + dmg = 30 + ) +class Potion(Item): + def __init__(health_plus): + self.health_plus = health_plus + super()__init__( + name = 'Health Potion' + description = 'Increase health points by 10 pts' + ) + +class Creature: + def __init__(self, name, hp, atk): + self.name = name + self.healthpoints = hp + self.attack = atk + + def is_alive(self): + return self.healthpoints > 0 + +class red_dragon(Creature): + def __init__(self): + super().__init__( + name = "Red Dragon" + hp = 100 + atk = 20 + ) + +class Blue_dragon(Creature): + def __init__(self): + super().__init__( + name = "Blue Dragon" + hp = 125 + atk = 30 + ) + +class Black_dragon(Creature): + def __init__(self): + super().__init__( + name = "Black Dragon" + hp = 150 + atk = 50 + ) \ No newline at end of file diff --git a/lab_assignments/cars/adventure_fun_time.py/player.py b/lab_assignments/cars/adventure_fun_time.py/player.py new file mode 100644 index 0000000..b1e0343 --- /dev/null +++ b/lab_assignments/cars/adventure_fun_time.py/player.py @@ -0,0 +1,51 @@ +import game_parts + +class Player(): + def __init__(self): + self.inventory = [Item.r_sword(), Item.Potion()] + self.hp = 100 + self.location_x, self.location_y = world.starting_position + self.victory = False + + def is_alive(self): + return self.hp > 0 + + def print_inventory(self): + for item in self.inventory: + print(item, '\n') + def move(self, dx, dy): + self.location_x += dx + self.location_y = dy + print(world.tile_exists(self.location_x, self.location_y).intro_text()) + + def move_up(self): + self.move(dx=0, dy=-1) + + def move_down(self): + self.move(dx=0, dy=-1) + + def move_left(self): + self.move(dx=1, dy=0) + + def move_right(self): + self.move(dx=-1, dy=0) + + def attack(self, enemy): + best_weapon = None + max_dmg = 0 + for i in self.inventory: + if isinstance(i, Item.Weapon): + if i.damage > max_dmg: + best_weapon = i + print("You use {} against {}!".format(best_weapon.name, enemy.name)) + enemy.hp -= best_weapon.damage + if not enemy.is_alive(): + print("you Killed {}!".format(enemy.name)) + + def do_action(self, action, **kwargs): + action_method = getattr(self, action.method.__name__) + if action_method: + action_method(**kwargs) + + else: + print("{}HP is {}.".format(enemy.name, enemy.hp)) diff --git a/lab_assignments/cars/adventure_fun_time.py/tiles.py b/lab_assignments/cars/adventure_fun_time.py/tiles.py new file mode 100644 index 0000000..486f139 --- /dev/null +++ b/lab_assignments/cars/adventure_fun_time.py/tiles.py @@ -0,0 +1,164 @@ +import Weapon, Item, Creature, World + +class MapTiles: + def __init__(self, x, y): + self.x = x + self.y = y + + def intro_text(self): + raise NotImplementedError() + + def modify_player(self, player): + raise NotImplementedError() + + def adjacent_moves(self): + if world.tile_exists(self.x + 1, self.y): + moves.append(actions.left()) + + if world.tile_exists(self.x - 1, self.y): + moves.append(actions.right()) + + if world.tile_exists(self.x, self.y - 1): + moves.append(actions.up()) + + if world.tile_exists(self.x, self.y +1): + moves.append(actions.down()) + + return moves + def available_actions(self): + """Returns all of the Available actions in this room + """ + moves = self.adjacent_moves() + moves.append(action.ViewInventory()) + return moves + +class StartRoom(MapTiles): + def intro_text(self): + """ + {}, are you awake now? + We were attacked by a {} and now the town is on fire. + While we put out the flames you've got to find that + wretched creature and destroy him! + + """.formate(player, creature) + + def modify_player(self, player): + #Room has no action on player + pass + +class HideItem(MapTile): + def __init__(self, X, y, item): + self.item = item + super().__init__(x, y) + + def add_item(self, player): + player.inventory.append(self.item) + + def modify_player(self, player): + self.add_item(player) + +class HideCreature(MapTile): + def _init__(self, x, y, enemy): + self.enemy = enemy + super().__init__(x, y) + + def modify_player(self, the_player): + if self.enemy.is_alive(): + the_player.hp = the_player.hp - self.enemy.damage + print("{} does {} damage.\nYou have {} HP remaining.".format(creature.name, self.enemy.damage, the_player.hp)) + + def available_actions(self): + if self.enemy.is_alive(): + the_player.hp = the_player.hp - self.enemy.damage + return [actions.Flee(tile=self), actions.Attack(creature=self.creature)] + else: + return self.adjacent_moves() + +class HideRdDragon(HideCreature): + def __init__(self, x, y): + super().__init__(x, y, creatures.red_dragon()) + + def intro_text(self): + if self.creature.is_alive(): + return """ + You find yourself face to face with a Red Dragon. It's belly warm with fire + he lets out a deafening screech. + """ + else: + return """ + The carcaus is still warm from your previous battle. + """ + +class HideBlDragon(HideCreature): + def __init__(self, x, y): + super().__init__(x, y, Creature.blue_dragon()) + + def intro_text(self): + if self.creature.is_alive(): + return """ + You find yourself face to face with a Blue Dragon. She doesn't like to be disturbed. + The dragon lunges at you. + """ + else: + return """ + The carcaus is still warm from your previous battle. + """ + +class HideBlkDragon(HideCreature): + def __init__(self, x, y): + super().__init__(x, y, Creature.black_dragon()) + + def intro_text(self): + if self.creature.is_alive(): + return """ + You find yourself face to face with a Black Dragon. + He lays in a valcano that seems to be the fuel for his rage. + """ + else: + return """ + The carcaus is still warm from your previous battle. + """ +class HidePotion(HideItem): + def __init__(self, x, y): + super().__init__(x, y, Item.Potion()) + + def intro_text(self): + return """ + You have found a potion, it will bring you back to life. + """ + +class HideRdSword(HideItem): + def __init__(self, x, y): + super().__init__(x, y, Item.r_sword()) + + def intro_text(self): + return """ + You have found a sword that shines Red. + """ + +class HideCSword(HideItem): + def __init__(self, x, y): + super().__init__(x, y, Item.c_sword()) + + def intro_text(self): + return """ + You have found a sword that shines blue. + """ + +class HideDSword(HideItem): + def __init__(self, x, y): + super().__init__(x, y, Item.d_sword()) + + def intro_text(self): + return """ + You have found a sword that shines with a white light. + """ + +class Victory(MapTiles): + def intro_text(self): + return """ + You have defeated the great dragon and saved our land! + """ + + def modify_player(self, player): + player.victory = True \ No newline at end of file diff --git a/lab_assignments/cars/blackjack/__pycache__/cards.cpython-36.pyc b/lab_assignments/cars/blackjack/__pycache__/cards.cpython-36.pyc new file mode 100644 index 0000000..8777a56 Binary files /dev/null and b/lab_assignments/cars/blackjack/__pycache__/cards.cpython-36.pyc differ diff --git a/lab_assignments/cars/blackjack/blackjack.py b/lab_assignments/cars/blackjack/blackjack.py new file mode 100644 index 0000000..67ec05e --- /dev/null +++ b/lab_assignments/cars/blackjack/blackjack.py @@ -0,0 +1,22 @@ +#Main game file +print('Would you like to start a new game of Black Jack?: Y or N') +start = input().lower() + +yes = 'y' +no = 'n' + +print('player one score: \n' +'hand: \n' +'cards played: \n') + +print('Dealer one score: \n' +'hand: \n' #have the number of cards but remove the value +'cards played: \n') + +#Start a new game + +#Score a hand + +#Bust if the score is over 21 + +#Bust if the user draws more the 5 cards \ No newline at end of file diff --git a/lab_assignments/cars/blackjack/blackjack_table.py b/lab_assignments/cars/blackjack/blackjack_table.py new file mode 100644 index 0000000..a58ff54 --- /dev/null +++ b/lab_assignments/cars/blackjack/blackjack_table.py @@ -0,0 +1,59 @@ +import random + +class Card: + def __init__(self, suit, value): + self.suit = suit + self.value = value + + def show(self): + print('{} of {}'.format(self.suit, self.value)) + +class Deck: + def __init__(self): + self.cards = [] + self.build() + + def build(self): + for s in ['spades', 'clubs', 'diamonds', 'hearts']: + for v in range(1, 14): + self.cards.append(Card(s, v)) + + def show(self): + for c in self.cards: + c.show() + + def shuffle(self): + for i in range(len(self.cards)-1, 0, -1): + r = random.randint(0, i) + self.cards[i], self.cards[r] = self.cards[r], self.cards[i] + + def draw(self): + return self.cards.pop() + + +class Player: + def __init__(self, name): + self.name = name + self.hand = [] + + def draw(self, deck): + self.hand.append(deck.draw()) + return self + + def showhand(self): + for card in self.hand: + card.show() + + def discard(self): + return self.hand.pop() + +deck_1 = Deck() +deck_1.shuffle() + +player_1 = Player("Player 1") +player_1.draw(deck_1).draw(deck_1) +player_1.showhand() + +dealer_1 = Player("Dealer 1") +dealer_1.draw(deck_1).draw(deck_1) +dealer_1.showhand() \ No newline at end of file diff --git a/lab_assignments/cars/blackjack/cards.py b/lab_assignments/cars/blackjack/cards.py new file mode 100644 index 0000000..376fac1 --- /dev/null +++ b/lab_assignments/cars/blackjack/cards.py @@ -0,0 +1,85 @@ +# #give cards suit and rank +# import random + +# card_values = { +# 'Ace': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, '10': 10, 'jack': 10, 'queen': 10, 'king': 10 +# } + +# suits = ['Hearts', 'Diamonds', 'Spades', 'Clubs'] + +# class Card: +# def __init__(self, suit, rank, value): +# self.suit = suit +# self.rank = rank + +# def __str__(self): +# return '{} of {}'.format(self.rank, self.suit) + +# def __repr__(self): +# return '{} of {}'.format(self.rank[0], self.suit) + +# class Deck: +# def __init__(self, suit, rank, value): +# self.cards = [Card(suit, rank) for s in suit for r in rank] +# self.shuffle() + +# def __str__(self): +# deck_cards = '' +# for cards in self.cards: +# deck_cards = deck_cards + str(card) + '' +# return deck_cards + +# def shuffle(self): +# random.shuffle(self.cards) + +# def deal_card(self): +# card = self.cards.pop(0) +# return cards + +# class Hand: +# def __init__(self): +# self.hand = [] + +# def add_card(self, card): +# self.hand.append(card) +# return self.hand + +# def get_value(self): +# aces = 0 +# value = 0 +# for card in self.hand: +# if Card.is_ace(): +# aces =+ 1 +# value += card.point +# while (value > 21) and aces: +# value -= 10 +# aces -= 1 +# return value + +import random + +card_values = { + 'Ace': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, '10': 10, 'jack': 10, 'queen': 10, 'king': 10 + } + +suits = ['Hearts', 'Diamonds', 'Spades', 'Clubs'] + +class Card: + def __init__(self, suit, rank, value): + self.suit = suit + self.rank = rank + self.value = value + + def __str__(self): + return '{} of {}'.format(self.rank, self.suit) + + def __repr__(self): + return '{} of {}'.format(self.rank[0], self.suit[0]) + +deck = [] + +for s in suits: + for rank, value in card_values.items(): + deck.append(Card(s, rank, value)) +random.shuffle(deck) + return deck \ No newline at end of file diff --git a/lab_assignments/cars/blackjack/deck.py b/lab_assignments/cars/blackjack/deck.py new file mode 100644 index 0000000..8bb3da1 --- /dev/null +++ b/lab_assignments/cars/blackjack/deck.py @@ -0,0 +1,14 @@ +import cards +import random + +print(Card()) + +class Deck(Card): + deck = [] + for s in suits: + for rank, value in card_values.items(): + deck.append(Card(s, rank, value)) + random.shuffle(deck) + return deck + +print(Deck()) \ No newline at end of file diff --git a/lab_assignments/cars/blackjack/hand.py b/lab_assignments/cars/blackjack/hand.py new file mode 100644 index 0000000..e69de29 diff --git a/lab_assignments/cars/cars.py b/lab_assignments/cars/cars.py new file mode 100644 index 0000000..b1d569c --- /dev/null +++ b/lab_assignments/cars/cars.py @@ -0,0 +1,13 @@ +class Car: + def __init__(self, color, doors, wheels=4, ): + self.wheels = wheels + self.color = color + self.doors = doors + self.honk = 'honk' + +blue_car = Car('Blue', '4') +green_car = Car('Green', '8') +red_car = Car('Red', '2') + +# print('Your car is ' + red_car.color + ' with ' + red_car.doors + ' doors.') +# print(red_car.honk, red_car.honk) \ No newline at end of file diff --git a/lab_assignments/cars/classes2.py b/lab_assignments/cars/classes2.py new file mode 100644 index 0000000..e69de29 diff --git a/lab_assignments/cars/main.py b/lab_assignments/cars/main.py new file mode 100644 index 0000000..2907e18 --- /dev/null +++ b/lab_assignments/cars/main.py @@ -0,0 +1,10 @@ +import cars + +print('Your car is ' + cars.red_car.color + ' with ' + cars.red_car.doors + ' doors.') +print(cars.red_car.honk, cars.red_car.honk) + +print('Your car is ' + cars.blue_car.color + ' with ' + cars.blue_car.doors + ' doors.') +print(cars.blue_car.honk, cars.blue_car.honk) + +print('Your car is ' + cars.green_car.color + ' with ' + cars.green_car.doors + ' doors.') +print(cars.green_car.honk, cars.green_car.honk) \ No newline at end of file diff --git a/lab_assignments/change_return.py b/lab_assignments/change_return.py new file mode 100644 index 0000000..28e8ecc --- /dev/null +++ b/lab_assignments/change_return.py @@ -0,0 +1,46 @@ +# Some supermarkets have automatic change dispensers. +# Ask for the amount of change to dispense in cents. +# Assume that the amount input will be less than 100 cents. +# Calculate the number of quarters necessary first. +# Then calculate the number of dimes, nickels, and pennies. +# If you do it in that order, you will minimize the number of coins. +# This is easiest done by updating a running total of number of cents left to be put into coins. +# Also remember that the // operator divides and removes any remainder. + +#if the number is less than 100 contiune to the next step +#divide the change by 25 +#the modulus of the number divided by 25 should be divided by 10 +#the modulus of that number will be divided until the number is zero + +#Message +welcome = print('Without the decimal enter your amount of change: ') +purchase = int(input()) +round_1 = int() +round_2 = int() +round_3 = int() +quarters = int() +dimes = int() +nickles = int() +pennies = int() + +def mk_quarters(purch): + quarters = purchase // 25 + round_1 = purchase % 25 + return round_1, quarters +def mk_dimes(round1): + dimes = round_1 // 10 + round_2 = round_1 % 10 + return round_2, dimes +def mk_nickles(round2): + nickles = round_2 // 5 + round_3 = round_2 % 5 + return round_3, nickles +def mk_pennies(round3): + pennies = round_3 + +mk_quarters(purchase) +mk_dimes(round_1) +mk_nickles(round_2) +mk_pennies(round_3) + +print('Quarters {q}, dimes {d}, nickles {n}, pennies {p}'.format(q=quarters, d=dimes, n=nickles, p=pennies)) diff --git a/lab_assignments/classes.py b/lab_assignments/classes.py new file mode 100644 index 0000000..c551e39 --- /dev/null +++ b/lab_assignments/classes.py @@ -0,0 +1,55 @@ +#requiremnets: +#name +#account number +#account balance +#phone number + +# accounts = { +# 00001: { +# 'name: chriss', +# 'phone': 8328584422, +# 'balance': 10 +# } +# } + +NUMBER_OF_ACCOUNTS = 0 + +class BankAccount: + def __init__(self, client_name): + self.account_number = self.assign_account_number() + self.name = client_name + self.balance = 0 + self.phone = phone + + def assign_account_number(self): + global NUMBER_OF_ACCOUNTS + NUMBER_OF_ACCOUNT += 1 + return NUMBER_OF_ACCOUNTS + + def deposit(self, amount): + self.bank += amount + print("thanks {}! Your Balance is now{}.".format(self.name, self.balance)) + + def widthdrawl(self, amount): + if self.balance - amount >= 0: + self.bank -= amount + print("thanks {}! Your Balance is now{}.".format(self.name, self.balance)) + else: + print('I\'m sorry {}, you do not have enough moeny for that.') + +class BankAccountPlus(BankAccount): + def __init__(self,client_name): + super().__init__(name, phone) + + def widthdrawl(self, amount): + if self.balance - amount >= 100: + self.bank -= amount + print("thanks {}! Your Balance is now{}.".format(self.name, self.balance)) + elif 100 > self.balance - amount: + print('I\'m sorry {}, you do not have enough moeny for that.') + +chris_account = BankAccount('chris') +sheri_account = BankAccount('sheri') + +print(sheri_account.name) +print(chris_account.name) \ No newline at end of file diff --git a/lab_assignments/classes2.py b/lab_assignments/classes2.py new file mode 100644 index 0000000..e69de29 diff --git a/lab_assignments/create_car.py b/lab_assignments/create_car.py new file mode 100644 index 0000000..e69de29 diff --git a/lab_assignments/credit_card.py b/lab_assignments/credit_card.py new file mode 100644 index 0000000..6a41900 --- /dev/null +++ b/lab_assignments/credit_card.py @@ -0,0 +1,11 @@ +import doctest + +def cc_validation(n): + + card_number = list(n) + card_number.pop() + card_number.reverse() + sum(card_number) + return card_number + +print(cc_validation(input())) \ No newline at end of file diff --git a/lab_assignments/data_example.json b/lab_assignments/data_example.json new file mode 100644 index 0000000..2534d6e --- /dev/null +++ b/lab_assignments/data_example.json @@ -0,0 +1,12 @@ +{ +"glossary":{ + "title": "example glossary"', +"GlossDiv":{ + "title":5, + + +} + +} + +} \ No newline at end of file diff --git a/lab_assignments/extract_header.py b/lab_assignments/extract_header.py new file mode 100644 index 0000000..4567ce1 --- /dev/null +++ b/lab_assignments/extract_header.py @@ -0,0 +1,6 @@ +#Extract Header + +email_in = input('What is your email address: ') +email_wo_com = email_in[0:-4] +fin_email = email_wo_com.split('@') +print(fin_email[1]) diff --git a/lab_assignments/file_io.py b/lab_assignments/file_io.py new file mode 100644 index 0000000..2102ffd --- /dev/null +++ b/lab_assignments/file_io.py @@ -0,0 +1,47 @@ +# #read **sample code only** +# open('text_file.tx', 'r') +# f = open('text name', 'r') +# print(f.read()) + +# content = f.read() +# new_content = content.replace('l','1') +# f.close() + +# wf = open('text_file.txt', 'w') +# wf.write(new_content) +# wf.close() +# #write a file / overright everything +# open('', 'w') +# wf = open('text_file.txt', 'w') +# wf.write(new_content) +# wf.close() + +# #delete +# open(, 'x') +# #open a file that already exist +# open(, 'a') +# with open('text_file.txt', 'r+') as f: +# lines = [i.replace('\n', '') for i in f.readlines()] + +# #this is just the same line above in a different syntax + +# #for i in f.readlines(): +# # lines.append(i.replace('\n', '')) + +# # lines = f.readlines() +# # lines_no_newlines = [] +# # for i in lines: +# # lines_no_newlines.append(i.replace('\n', '')) +# # lines = lines_no_newlines[:] + +# print(lines) +# for l in lines: +# print(l) + +import json + +with open('data_example.json', 'r') as f: + data = json.loads(f.read()) + +for i in range(len(data)): + data[i]['glossary']['title'] = 'A new title for this thing x {'.format('*'(i+1)) \ No newline at end of file diff --git a/lab_assignments/fizz_buzz.py b/lab_assignments/fizz_buzz.py new file mode 100644 index 0000000..a47c7de --- /dev/null +++ b/lab_assignments/fizz_buzz.py @@ -0,0 +1 @@ +#Fizz Buzz diff --git a/lab_assignments/greeting.py b/lab_assignments/greeting.py new file mode 100644 index 0000000..0704237 --- /dev/null +++ b/lab_assignments/greeting.py @@ -0,0 +1,8 @@ +#Greetings + +name = input('What is your name?: ') +age = input('How old are you?: ') +bday = int(age) +1 +message = 'Hello {n}, you will be {b} next year!'.format(n=name, b=bday) + +print(message) diff --git a/lab_assignments/guessing_game_1.py b/lab_assignments/guessing_game_1.py new file mode 100644 index 0000000..2b156c3 --- /dev/null +++ b/lab_assignments/guessing_game_1.py @@ -0,0 +1,21 @@ +import random +import time + +c_number = random.randint(1, 10) +guess_int = 0 +def guess(): + entry = input('what number am I thinking?') + guess_int = int(entry) + +while (guess_int != c_number): + guess() + if guess_int > c_number: + print('You\'re too high.') + + if guess_int < c_number: + print('You\'re too low.') +if guess_int == c_number: + print('Congradulations, you\'re prize is self reflection on the time you\'ve wasted!') + replay = input('would you like to play again?: ').lower() + if replay == 'y': + print(entry) diff --git a/lab_assignments/guessing_game_2.py b/lab_assignments/guessing_game_2.py new file mode 100644 index 0000000..2e9de37 --- /dev/null +++ b/lab_assignments/guessing_game_2.py @@ -0,0 +1,23 @@ +import random + +low = 0 +high = 10 +response = '' +c_guess = random.randint(low,high) +s_number = input('what is your number?' ) + +while response != 'yes': + print('is it', c_guess,'?' ) + response = input() + if response == 'higher': + low = c_guess + 1 + c_guess = random.randint(low,high) + elif response == 'lower': + high = c_guess - 1 + c_guess = random.randint(low, high) + pass + elif response == 'yes': + print('whoo hoo!') + break + else: + print('only higher lower or yes are valid responses.') \ No newline at end of file diff --git a/lab_assignments/hammer_time.py b/lab_assignments/hammer_time.py new file mode 100644 index 0000000..6f552ff --- /dev/null +++ b/lab_assignments/hammer_time.py @@ -0,0 +1,37 @@ +... +time = input('Enter time using 24hr format (example 0800): ') +num = time[0:2] + +breakfast = 'It\'s breakfast time!' +lunch = 'It\'s lunch time!' +dinner = 'It\'s dinner time!' +hammer = 'Lets be real, it\'s always hammer time' +no_meal = 'No meal served at this time.' + +if num == ('07'or'08'or'09'): + print(breakfast) +elif num == ('12'or'13'or'14'): + print(lunch) +elif num == ('19'or'20'or'21'): + print(dinner) +elif num == ('22'or'23'or'24'or'01'or'02'or'03'or'04'): + print(hammer) +else: + print(no_meal) + +time = input('What time is it?(HH:MM:am/pm)').lower() + +hour, minute, merd = time.split(':') + +if merd == 'am': + #if hour == ()'07' or '08' or '09'): + if hour == ['07', '08', '09']: + print('Breakfast') + elif hour in ['', '01', '02', '03', '04']: + print('Hammer Time') + else: + print('Go to sleep') + else: + if hour in ['12', '01', '02',]: + print('Lunch Time') + elif hour in ['07', '08', '09']: diff --git a/lab_assignments/letter_locator.py b/lab_assignments/letter_locator.py new file mode 100644 index 0000000..d0a2615 --- /dev/null +++ b/lab_assignments/letter_locator.py @@ -0,0 +1,14 @@ +#Letter Locator +print('Please enter a setence to parse: ') +r_sentence = input() +print('What letter would you like to find?: ') +p_key = input() +counter = r_sentence.count(p_key) + +def l_find(sentence, key): + try: + start = sentence.find(key) + return [(c, i) for i, c in enumerate(sentence,start) if c == key] + except ValueError: + return 'this character can not be found in the provided statement' +print(l_find(r_sentence, p_key)) \ No newline at end of file diff --git a/lab_assignments/list_doubles.py b/lab_assignments/list_doubles.py new file mode 100644 index 0000000..f2a737f --- /dev/null +++ b/lab_assignments/list_doubles.py @@ -0,0 +1,7 @@ +#List Doubles +lst = [1, 2, 3, 4, 5, 6, 7] +m = 2 +lst_2 = [i * m for i in lst] + +print(lst) +print(lst_2) \ No newline at end of file diff --git a/lab_assignments/madlib.py b/lab_assignments/madlib.py new file mode 100644 index 0000000..18de905 --- /dev/null +++ b/lab_assignments/madlib.py @@ -0,0 +1,8 @@ +noun = input('Name a person, place or thing: ') +build = input('Name something you can build: ') +adjective = input('Give an adjective: ') +build_top = input('Another thing you can build: ') + +madlib = 'Look at all the {n}! I\'m going to build a {b}! I\'ll decorate it with {a} paint. I can even build a {b2} on top of it'.format(n=noun, b=build, a=adjective, b2=build_top) + +print(madlib) diff --git a/lab_assignments/magic_ball.py b/lab_assignments/magic_ball.py new file mode 100644 index 0000000..3950e7e --- /dev/null +++ b/lab_assignments/magic_ball.py @@ -0,0 +1,18 @@ +import sys +import random + +print('Ask the the Eight Ball whatever you desire: ') +question = input() +answer = random.randint(1, 3) + +def ans(rand): + if rand is 1: + return 'You probably shouldn\'t ask a stranger this' + elif rand is 2: + return 'you are thinking about this way to much...' + elif rand is 3: + return '...like a weird amount' + + + +print(ans(answer)) \ No newline at end of file diff --git a/lab_assignments/pig_latin.py b/lab_assignments/pig_latin.py new file mode 100644 index 0000000..7557d85 --- /dev/null +++ b/lab_assignments/pig_latin.py @@ -0,0 +1,12 @@ +#pig Latin Translator + +pig = 'ay' +o_word = input('What word would you like to translate?: ') +word = o_word.lower() +first = word[0] +if first == ('a' or 'e' or 'i' or 'o' or 'u'): + new_word = word + pig + print(new_word) +else: + new_word = word[1:] + first + pig + print(new_word) diff --git a/lab_assignments/recursion.py b/lab_assignments/recursion.py new file mode 100644 index 0000000..c677fbe --- /dev/null +++ b/lab_assignments/recursion.py @@ -0,0 +1,31 @@ +import datetime +# def fib(n): +# if n == 0: +# return 0 +# elif n == 1: +# return 1 +# else: +# print('n = {}'.format(n)) +# return fib(n-1) + fib(n-2) +# def +# def timer(function): +# start = datetime.datetime.now() +# results = function(*args, **kwargs) +# end = datetime.datetime.now() +# print(end - start) +# return results +# return timed + +# timed_fib = timer(fib) +# print(timed_fib(5)) + +def contains_factory(x): + def contains(lst): + return x in lst + return contains + +l = [1, 22, 15, 7, 8, 66] +contains_22 = contains_factory(22) +contains_55 = contains_factory(55) + +print(contains_55(l)) \ No newline at end of file diff --git a/lab_assignments/roi_cipher.py b/lab_assignments/roi_cipher.py new file mode 100644 index 0000000..efc8342 --- /dev/null +++ b/lab_assignments/roi_cipher.py @@ -0,0 +1,56 @@ +#ROT13 Cipher +max_difficulty = 10 + +def get_mode(): + while True: + print('Do you wish encrypt or decrypt a message?: ') + mode = input().lower() + if mode[0] == 'e': + return mode + elif mode[0] == 'd': + return mode + else: + print('That is an invalid input.') + +def get_message(): + print('Enter your message') + return input() + +def get_difficulty(): + difficulty = 0 + while True: + print('Enter a number to rotate your encryption difficulty (1-%s)' % (max_difficulty)) + difficulty = int(input()) + if (difficulty >= 1 and difficulty <= max_difficulty): + return difficulty + +def translated_message(mode, difficulty, message,): + if mode[0] == 'd': + difficulty = -difficulty + translated = '' + + for symbol in message: + if symbol.isalpha(): + num = ord(symbol) + num += difficulty + + if symbol.isupper(): + if num > ord('Z'): + num -= 26 + elif symbol.islower(): + if num > ord('z'): + num -= 26 + elif num < ord('a'): + num += 26 + translated += chr(num) + else: + translated += symbol + return translated + +mode = get_mode() +message = get_message() +difficulty = get_difficulty() + +print('your translated message is: ') +print(translated_message(mode, difficulty, message)) + diff --git a/lab_assignments/shrink.py b/lab_assignments/shrink.py new file mode 100644 index 0000000..fdc6d39 --- /dev/null +++ b/lab_assignments/shrink.py @@ -0,0 +1,14 @@ +#Shrink! +num_str = sum([1, 2, 3, 4]) + +def shrink(lst): + i = str(lst) + + if len(i) <= 1: + return i + else: + return shrink(lst) + +print(shrink(num_str)) + + \ No newline at end of file diff --git a/lab_assignments/string_methods.py b/lab_assignments/string_methods.py new file mode 100644 index 0000000..abe5cab --- /dev/null +++ b/lab_assignments/string_methods.py @@ -0,0 +1,6 @@ +words = 'Antidisestablishmentterianism' +also_words = 'Pneumonoultramicroscopicsilicovolcanoconiosis' + +print(words.count('i')) +print(also_words.lstrip() [0:5]) +print(also_words.strip()[-15]) \ No newline at end of file diff --git a/lab_assignments/text_file.txt b/lab_assignments/text_file.txt new file mode 100644 index 0000000..e68d7ad --- /dev/null +++ b/lab_assignments/text_file.txt @@ -0,0 +1,3 @@ +This is our text +this is the second line of the text +this is the third line of text \ No newline at end of file diff --git a/lab_assignments/unit_converter.py b/lab_assignments/unit_converter.py new file mode 100644 index 0000000..2a4e1c1 --- /dev/null +++ b/lab_assignments/unit_converter.py @@ -0,0 +1,4 @@ +mile = 5280 +feet = int(input('Enter number of miles: ')) + +print(mile*feet) diff --git a/lab_assignments/wall_painting.py b/lab_assignments/wall_painting.py new file mode 100644 index 0000000..e0798e5 --- /dev/null +++ b/lab_assignments/wall_painting.py @@ -0,0 +1,13 @@ +#Wall Painting +import math + +width = input('How tall is the wall you\'re paiting?: ') +height = input('How wide is the wall you\'re painting?: ') +cost = input('How much does paint cost at your local store per gallon?: ') +calc_area = int(width) * int(height) +calc_gal = calc_area / 400 +calc_gal_2 = math.ceil(calc_gal) +calc_cost = calc_gal_2 * float(cost) + + +print(calc_cost)