Saturday, November 19, 2016

Random Python Programs November 20 2016

Deck Builder Program v1

def program1(deckname,nameofdeck):
  print("----------------------")
  if (len(deckname)) < 40:
    print("*This deck is below the deck minimum.*")
  if (len(deckname)) > 60:
    print("*This deck is past the deck limit.*")
  print(nameofdeck)
  print(deckname)
  print ("Number of cards in deck:",len(deckname))
  action = input("Rename your deck, add a card to your deck, remove a card from your deck,  check if a card is in a deck, or check how many of card is in your deck (rename),(add),(remove),(check):")
  if action == "rename":
    print("----------------------")
    newname = input("What would you like to rename your deck?:")
    (newname) = (deckname)
    deckname = (newname)
    nameofdeck = (newname)
    program1(deckname,nameofdeck)
  if action == "add":
    print("----------------------")
    add = input("What Card Would you like to Add to The Deck?:")
    counter = int(input("How many copies would you like to add to the deck?:"))
    while counter>0:
      deckname.append(add)
      counter -= 1
      program1(deckname,nameofdeck)
  if action == "remove":
    print("----------------------")
    remove = input ("What Card Would you like to Remove From The Deck?:")
    counter = int(input("How many copies would you like to remove from the deck?:"))
    while counter>0:
      deckname.remove(remove)
      counter -= 1
      program1(deckname,nameofdeck)
  if action == "check":
    print("----------------------")
    check = input("What would you like to check: Number of Card in Deck (number) or If a Card is in Deck (if)?:")
    if check == "number":
      print("----------------------")
      number = input("What card would you like to count in the deck?:")
      print(number,"occurs",deckname.count(number),"times in this deck.")
      program1(deckname,nameofdeck)
    if check == "if":
      print("----------------------")
      check = input("What card would you like to check to see if it is in the deck?:")
      if check in deckname:
        print(check, "is in",nameofdeck)
        program1(deckname,nameofdeck)
      else:
        print(check,"is not in",nameofdeck)
        program1(deckname,nameofdeck)
deckname = input("What would you like to name this deck?:")
nameofdeck = (deckname)
(deckname) = []
program1(deckname,nameofdeck)

Deck Builder Program v2

def program1(deckname,nameofdeck):
  print("----------------------")
  if (len(deckname)) < 40:
    print("*This deck is below the deck minimum.*")
  if (len(deckname)) > 60:
    print("*This deck is past the deck limit.*")
  print(nameofdeck)
  print(deckname)
  print ("Number of cards in deck:",len(deckname))
  action = input("Rename your deck, add a card to your deck, remove a card from your deck,  check if a card is in a deck, or check how many of card is in your deck (rename),(add),(remove),(check):")
  if action == "rename":
    print("----------------------")
    newname = input("What would you like to rename your deck?:")
    (newname) = (deckname)
    deckname = (newname)
    nameofdeck = (newname)
    program1(deckname,nameofdeck)
  if action == "add":
    print("----------------------")
    add = input("What Card Would you like to Add to The Deck?:")
    counter = int(input("How many copies would you like to add to the deck?:"))
    if (deckname.count(action)) == 3:
      print("You cannot add more than three copies of a card to your deck.")
      print("Action canceled")
      program1(deckname,nameofdeck)
    if counter > 3:
      print("You cannot add more than three copies of a card to your deck.")
      print("Action canceled")
      program1(deckname,nameofdeck)
    while counter>0:
      deckname.append(add)
      counter -= 1
      program1(deckname,nameofdeck)
  if action == "remove":
    print("----------------------")
    remove = input ("What Card Would you like to Remove From The Deck?:")
    counter = int(input("How many copies would you like to remove from the deck?:"))
    while counter>0:
      deckname.remove(remove)
      counter -= 1
      program1(deckname,nameofdeck)
  if action == "check":
    print("----------------------")
    check = input("What would you like to check: Number of Card in Deck (number) or If a Card is in Deck (if)?:")
    if check == "number":
      print("----------------------")
      number = input("What card would you like to count in the deck?:")
      print(number,"occurs",deckname.count(number),"times in this deck.")
      if (deckname.count(number)) > 3:
        print("There are too many copies of",number,"in the deck.")
      program1(deckname,nameofdeck)
    if check == "if":
      print("----------------------")
      check = input("What card would you like to check to see if it is in the deck?:")
      if check in deckname:
        print(check, "is in",nameofdeck)
        program1(deckname,nameofdeck)
      else:
        print(check,"is not in",nameofdeck)
        program1(deckname,nameofdeck)
deckname = input("What would you like to name this deck?:")
nameofdeck = (deckname)
(deckname) = []
program1(deckname,nameofdeck)

Deck Builder Program v3

def program1(deckname,nameofdeck):
  print("----------------------")
  if (len(deckname)) < 40:
    print("*This deck is below the deck minimum.*")
  if (len(deckname)) > 60:
    print("*This deck is past the deck limit.*")
  print(nameofdeck)
  print(deckname)
  print ("Number of cards in deck:",len(deckname))
  action = input("Rename your deck, add a card to your deck, remove a card from your deck,  check if a card is in a deck, or check how many of card is in your deck (rename),(add),(remove),(check):")
  if action == "rename":
    print("----------------------")
    newname = input("What would you like to rename your deck?:")
    (newname) = (deckname)
    deckname = (newname)
    nameofdeck = (newname)
    program1(deckname,nameofdeck)
  if action == "add":
    print("----------------------")
    add = input("What Card Would you like to Add to The Deck?:")
    counter = int(input("How many copies would you like to add to the deck?:"))
    if (deckname.count(action)) == 3:
      print("You cannot add more than three copies of a card to your deck.")
      print("Action canceled")
      program1(deckname,nameofdeck)
    if counter > 3:
      print("You cannot add more than three copies of a card to your deck.")
      print("Action canceled")
      program1(deckname,nameofdeck)
    while counter>0:
      deckname.append(add)
      counter -= 1
      program1(deckname,nameofdeck)
  if action == "remove":
    print("----------------------")
    remove = input ("What Card Would you like to Remove From The Deck?:")
    counter = int(input("How many copies would you like to remove from the deck?:"))
    while counter>0:
      deckname.remove(remove)
      counter -= 1
      program1(deckname,nameofdeck)
  if action == "check":
    print("----------------------")
    check = input("What would you like to check: Number of Card in Deck (number) or If a Card is in Deck (if)?:")
    if check == "number":
      print("----------------------")
      number = input("What card would you like to count in the deck?:")
      print(number,"occurs",deckname.count(number),"times in this deck.")
      if (deckname.count(number)) > 3:
        print("There are too many copies of",number,"in the deck.")
      program1(deckname,nameofdeck)
    if check == "if":
      print("----------------------")
      check = input("What card would you like to check to see if it is in the deck?:")
      if check in deckname:
        print(check, "is in",nameofdeck)
        program1(deckname,nameofdeck)
      else:
        print(check,"is not in",nameofdeck)
        program1(deckname,nameofdeck)
deckname = input("What would you like to name this deck?:")
nameofdeck = (deckname)
(deckname) = []
program1(deckname,nameofdeck)

Deck Builder Program v4


No comments:

Post a Comment