# gender=input('请输入您的性别:')
# age=input('请输入您的年龄:')

def isdigit_num():
    while True:
        value_age = input('请输入您的年龄:')
        if value_age.isdigit():
            return int(value_age)
        else:
            print('请再次输入正确的数字年龄')

while True:
    gender = input('请输入您的性别(F/M):').upper()
    age = isdigit_num()
    print('***你今年的运势***')
    if gender == 'F':
        if age <= 19:
            print('你会考上清华并找到一个男朋友')
        elif age <= 29:
            print('你会找到好工作')
        else:
            print('你会升职')
        break
    elif gender == 'M':
        if age  <= 19:
            print('你会考上清华并找到一个女朋友')
        elif age <=29:
            print('你会找到好工作')
        else:
            print('你会升职')
        break
    else:
        print('请再次输入正确性别(F/M)')
# -*- coding: utf-8 -*-
# @Author: AI悦创
# @Date:   2021-09-27 16:48:54
# @Last Modified by:   aiyc
# @Last Modified time: 2021-09-28 09:37:10
# import os
# os.renames("C:\\Users\\clela\\Desktop\\new_aiyc\\1.2klly.pptx", "C:\\Users\\clela\\Desktop\\book\\1.book.pptx")

# gender=input('请输入您的性别:')
# age=input('请输入您的年龄:')

def isdigit_num():
    value_age = input('请输入您的年龄:')
    if value_age.isdigit():
        return int(value_age)
    else:
        # print('请再次输入正确的数字年龄')
        return False

while True:
    gender = input('请输入您的性别(F/M):').upper()
    age = isdigit_num()
    if age:
        print('***你今年的运势***')
        if gender == 'F':
            if age <= 19:
                print('你会考上清华并找到一个男朋友')
            elif age <= 29:
                print('你会找到好工作')
            else:
                print('你会升职')
            break
        elif gender == 'M':
            if age  <= 19:
                print('你会考上清华并找到一个女朋友')
            elif age <=29:
                print('你会找到好工作')
            else:
                print('你会升职')
            break
        else:
            print('请再次输入正确性别(F/M)')
    else:
        print('请再次输入正确的数字年龄')

AI悦创·推出辅导班啦,包括「Python 语言辅导班、C++辅导班、算法/数据结构辅导班、少儿编程、pygame 游戏开发」,全部都是一对一教学:一对一辅导 + 一对一答疑 + 布置作业 + 项目实践等。QQ、微信在线,随时响应!V:Jiabcdefh

https://img-blog.csdnimg.cn/b70a1aed66e44d43aa1410f266193128.png

AI悦创·推出辅导班啦,包括「Python 语言辅导班、C++辅导班、算法/数据结构辅导班、少儿编程、pygame 游戏开发」,全部都是一对一教学:一对一辅导 + 一对一答疑 + 布置作业 + 项目实践等。QQ、微信在线,随时响应!V:Jiabcdefh
AI悦创 » 一对一学员运势作业点评

2 评论

  1. # -*- coding: utf-8 -*-
    # @Author: AI悦创
    # @Date:   2021-09-27 16:48:54
    # @Last Modified by:   aiyc
    # @Last Modified time: 2021-09-28 10:43:04
    # import os
    # os.renames("C:\\Users\\clela\\Desktop\\new_aiyc\\1.2klly.pptx", "C:\\Users\\clela\\Desktop\\book\\1.book.pptx")
    import random
    
    class Creature():
        def __init__(self, hp, name):
            self.hp = hp
            self.name = name
    
        def show_status(self):
            # print(self.hp)
            print(f"{self.name}' hp is {self.hp}.")
    
        def attack(self):
            # 随机
            attack_value = random.randint(0, 50)
            return attack_value
    
        def not_dead(self):
            if self.hp <= 0:
                return False
            else:
                return True
    
        def being_attack(self, attack_value):
            self.hp = self.hp - attack_value
    
    
    player = Creature(100, "AI悦创")
    enemy = Creature(80, "Enemy")
    
    
    while player.not_dead() and enemy.not_dead():
        player.show_status()
        enemy.show_status()
        userinput = input("Attack or Defence(A/D):").upper()
    
        if userinput == "A":
            player_attack_value = player.attack()
            enemy_attack_value = enemy.attack()
    
            enemy.being_attack(player_attack_value)
            player.being_attack(enemy_attack_value)
    
        elif userinput == "D":
            enemy_attack_value = enemy.attack() * 0.1
            player.being_attack(enemy_attack_value)
    
    if player.not_dead():
        print("You Win!")
    else:
        print("You lose!")
    
  2. # -*- coding: utf-8 -*-
    # @Author: AI悦创
    # @Date:   2021-09-27 16:48:54
    # @Last Modified by:   aiyc
    # @Last Modified time: 2021-09-28 10:03:14
    # import os
    # os.renames("C:\\Users\\clela\\Desktop\\new_aiyc\\1.2klly.pptx", "C:\\Users\\clela\\Desktop\\book\\1.book.pptx")
    
    dog_x = 0
    cat_x = 0
    snake_x = 0
    
    def dog_move():
        global dog_x
        dog_x += 10
    
    def cat_move():
        global cat_x
        cat_x += 10
    
    def snake_move():
        global snake_x
        snake_x += 10
    
    userinput = input(":>>>").lower()
    
    if userinput == "move":
        print(f"dog:{dog_x}, cat:{cat_x}, snake:{snake_x}")
        dog_move()
        cat_move()
        snake_move()
        print(f"dog:{dog_x}, cat:{cat_x}, snake:{snake_x}")
    

发表评论