zoukankan      html  css  js  c++  java
  • 第一章作业

    #import getpass


    1、猜年龄,可以让用户最多猜三次;

     1 age = 56
     2 n = 0
     3 
     4 while n < 3:
     5     guess_age = int(input ("pls input your guess_age(u get three times):"))
     6     n = n + 1
     7     if guess_age > age:
     8         print("pls smaller")
     9     elif guess_age < age:
    10         print("pls bigger")
    11     else:
    12         print("u got it!")



    #每隔三次,问他一下,还想不想继续玩;y,n

     1 age = 56
     2 n = 3
     3 a = 0
     4 while 0 == n%3 :
     5     dis = input("pay or not:")
     6     if dis == "y":
     7         while 1 == 1:
     8             n = n + 1
     9             guess_age = int(input("let's start again:"))
    10             if guess_age > age:
    11                 print("pls smaller")
    12             elif guess_age < age:
    13                 print("pls bigger")
    14             else:
    15                 break
    16     else:
    17         break



    待完善!

     1 # 输入用户名,密码,认证成功现实欢迎信息;输入三次后锁定;(程序退出,再次输入用户名不能进入;
     2 # 用户记录在文件里面)
     3 import getpass
     4 
     5 
     6 test_times = 3
     7 n = 0
     8 
     9 while n < test_times:
    10     n = n + 1
    11     user_guess = input("pls input your name:")
    12     user_password = getpass.getpass("pls input your password:")
    13     if user_guess == "alex" and user_password == "alex123" :
    14         print("welcome alex")
    15     else:
    16         print("u got wrong name or password")



  • 相关阅读:
    luogu P1075 质因数分解
    luogu P1146 硬币翻转
    [HEOI2013]SAO
    [HAOI2010]软件安装
    [CodeForces-763C]Timofey and remoduling
    [CodeForces-375E]Red and Black Tree
    [CodeForces-178F]Representative Sampling
    [CodeForces-55D]Beautiful Numbers
    [AHOI2009]同类分布
    [ZJOI2010]数字计数
  • 原文地址:https://www.cnblogs.com/santizhou/p/7226987.html
Copyright © 2011-2022 走看看