二手产品经理

二手产品经理

THIS IS RENO

Dictionary - 47 Days - Learn Python Online for 100 Days

Record#

  1. Today there are no new knowledge points, just practice.
  2. Today's practice is a bit confusing, but fortunately I managed to write it.

CODE#

import os
import time
import random

again = "y"
vuser = {}

vuser["zs"] = {"height": 180, "weight": 180, "beauty": 230, "intelligence": 100}
vuser["ls"] = {"height": 120, "weight": 190, "beauty": 50, "intelligence": 180}
vuser["ww"] = {"height": 111, "weight": 243, "beauty": 76, "intelligence": 10}
vuser["em"] = {"height": 90, "weight": 90, "beauty": 90, "intelligence": 90}


def userprint():
  i = 1
  for key in vuser.keys():
    print(f"{i} : {key}")
    i += 1


while again == "y":
  time.sleep(1)
  os.system("clear")
  print("🌟Top Trumps🌟")
  print()
  print(
    "Welcome to the Top Trumps 'Most Handsome Computing Teachers' Simulator")
  userprint()
  userselect = input("Please enter the card you want: ")
  while userselect not in vuser.keys():
    print(f"Input error, {userselect} is not in the cards")
    userselect = input("Please re-enter the card you want: ")
  aiselect = random.choice(list(vuser.keys()))
  while aiselect == userselect:
    aiselect = random.choice(list(vuser.keys()))
  print(f"The system has chosen {aiselect}")
  print()
  userinfo = input("Please enter the attribute you want to battle: \nheight\nweight\nbeauty\nintelligence\n")
  while userinfo not in vuser[userselect].keys():
    print(f"Input error, {userinfo} is not a valid choice")
    userinfo = input("Please re-enter the attribute you want to battle: \nheight\nweight\nbeauty\nintelligence\n")
  if vuser[userselect][userinfo] > vuser[aiselect][userinfo]:
    print("You win")
  elif vuser[userselect][userinfo] < vuser[aiselect][userinfo]:
    print("System wins")
  else:
    print("Draw")
  again = input("Again? y / n > ")

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.