The first brother doing their homework, if no specification writing, please review my big brother, I ask you to eat delicious yo

The first day of work

The first question: Today in class content to knock more than three times

print (a1)
print(a_1_a)
print(1_a)


print (a1)
print(a_1_a)
print(1_a)


print (a1)
print(a_1_a)
print(1_a)

age = 18
age1 = 20
print(age,age1)

age = 18
age1 = 20
print(age,age1)

age = 18
age1 = 20
print(age,age1)

age = 18
age1 = age
print(age,age1)

age = 18
age1 = age
print(age,age1)

age = 18
age1 = age
print(age,age1)

age = 18
age1 = age
age2 = age1
age = 20
age1 = 19
print(age,age1,age2)

age = 18
age1 = age
age2 = age1
age = 20
age1 = 19
print(age,age1,age2)

age = 18
age1 = age
age2 = age1
age = 20
age1 = 19
print(age,age1,age2)

a = 10
b = 5
print(a - b)
print(a + b)
print(a * b)
print(a / b)

a = 10
b = 5
print(a - b)
print(a + b)
print(a * b)
print(a / b)

a = 10
b = 5
print(a - b)
print(a + b)
print(a * b)
print(a / b)

a = "alex"
b = "123"
print("a,b")
print(a,b)

a = "alex"
b = "123"
print("a,b")
print(a,b)

a = "alex"
b = "123"
print("a,b")
print(a,b)

a = "坚持"
b = "Python26"
print(a + b * 5)


a = "坚持"
b = "Python26"
print(a + b * 5)

a = "坚持"
b = "Python26"
print(a + b * 5)

qq_user = input("QQ账号:")
qq_pwd = input("QQ密码:")
print(qq_user,qq_pwd)

qq_user = input("QQ账号:")
qq_pwd = input("QQ密码:")
print(qq_user,qq_pwd)

qq_user = input("QQ账号:")
qq_pwd = input("QQ密码:")
print(qq_user,qq_pwd)

num = input("请输入数字:")
print(type(num))
a = int(num)
print(a + 5)

num = input("请输入数字:")
print(type(num))
a = int(num)
print(a + 5)

num = input("请输入数字:")
print(type(num))
a = int(num)
print(a + 5)


user = input("username:")
pwd = input("password:")
if user == "alex" and pwd == "alex123":
    print(111)

user = input("username:")
pwd = input("password:")
if user == "alex" and pwd == "alex123":
    print(111)

user = input("username:")
pwd = input("password:")
if user == "alex" and pwd == "alex123":
     print(111)

The second question: name = input ( ">>>") verified by the code name variable is what type of data?

  • Answer: That is the type of string str type!

    • name = input("请输入你的名字:")
      print(type(name))
      print(name)
    • Screenshot:

Third question: if the basic structure of conditional statements?

  • The answer is as follows:

    • if - keyword, which is "if" means
    • = --------- it is "assignment" means
    • == --------- it is "equal" means
    • : ----------- it is "the end of the statement" means
    • ------- 4 indented spaces or Tab key, (Tab key can not be mixed and spaces)

      • If a single syntax

        if 条件:
           print(结果)
      • For example if a single theme:

      • if else (choose one) syntax

        if 条件:
           print(结果)
        else
           print(结果)
      • if else example screenshot:

      • if elif elif (a multiple choice or multiple choice zero) syntax

        if 条件:
           print(结果)
        elif 条件:
           print(结果)
        elif 条件:
           print(结果)
      • if elif elif example screenshot

      • if elif elif else (one of many) syntax

        if 条件:
           print(结果)
        elif 条件:
           print(结果)
        elif 条件:
           print(结果)
        else :
           print(结果)
      • if elif elif else example screenshot:

      • if nested syntax

        if 条件:
           if 条件:
              print(结果)
      • Examples nested if screenshot

      • For example

        sex = "男"
        age = 48
        if sex == "女":
            if age == 18:
                print("进来坐坐")
            else:
                print("隔壁找三哥")
        else:
            print("去对门找alex")
      • For example Screenshot

      • if if if (multiple choice and more) syntax in two ways:

        • The first
        if 条件:
           print(如果)
        if 条件:
           print(如果)
        if 条件:
           print(如果)
        
        • First syntax example screenshot

        • The second

        if 条件 and 条件:
            print(如果)
        
        • The second syntax example Screenshot

Fourth Question: The print prints out the following content

文能提笔安天下,
武能上马定乾坤.
心存谋略何人胜,
古今英雄唯世君.
  • The answer is as follows:

    print("文能提笔安天下,")
    print("武能上马定乾坤.")
    print("心存谋略何人胜,")
    print("古今英雄唯世君.")
    
    • Screenshot:

The fifth question: the use of an if statement written guess the size of the game:

An ideal setting numbers such as: 66, allowing users to enter a number, if larger than 66, the results show a big guess; if less than 66, the results show a small speculation; only equal to 66, the results show the correct guess.

  • answer

    b = int(input("请输入一个数字:"))
    if b > 66:
        print("你输入的数字有点大了!")
    elif b < 66:
        print("你输入的数字有点小!")
    else:
        print("恭喜你,猜对啦正确结果")
    
    • Code Screenshot:

Question 6: Tips Use the user to enter his age, by program into ⾏ judgment.

If less than 10, suggesting that kid actor, if greater than 10, less than 20, suggesting that adolescent rebellious kid actor. If greater than 20 and less than 30. The prompt start qualitative, began to mix social kid actor children, if greater than 30 and less than 40. Tip look appearing big deal, and quickly married kid actor children. If greater than 40 and less than 50. suggesting the family has a disobedient kid actor children. If greater than 50 and less than 60. remind ourselves immediately become disobedient old fart baby. If more than 60 , less than 70. Tip alive and good old fart baby. If greater than 70 and less than 90. Tip life is coming to an end of an old fart baby. If more than 90 or more. Tip goodbye to this world.

  • answer:

    user_age = int(input("请输入你的年龄:"))
    if user_age < 10:
        print("小屁孩")
    elif user_age > 10 and user_age < 20 :
        print("青春期叛逆的小屁孩")
    elif user_age > 20 and user_age < 30 :
        print("开始定性,开始混社会小屁孩儿")
    elif user_age >30 and user_age < 40 :
        print("看老老大不了,赶紧结婚小屁孩儿")
    elif user_age > 40 and user_age < 50:
        print("家里有个不听话的小屁孩儿")
    elif user_age > 50 and user_age < 60 :
        print("自己马上变成不听话的老屁孩儿")
    elif user_age > 60 and user_age < 70:
        print("活着还不错的老屁孩儿")
    elif user_age >70 and user_age < 90:
        print("人生就快结束了的一个老屁孩儿")
    elif user_age > 90:
        print("再见了这个世界!")
    
    • Screenshot

Q7: single-line comments and multiline comments?

  • answer:

    单行注释(当行注释),#用这个符号
    多行注释("""  内容 '""'),可以进行换行,遵循PEP8开发规范,建议使用这种方法
    

第八题:简述你所知道的Python3x和Python2x的区别?

  • 答案:

     python2:
            源码不统一
            有重复代码
            整型的除法:整数
            print 不加括号也可以
            input() 输入什么类型就是什么类型
            raw_input() 获取到的都是字符串
    
    
     python3:
            源码统一
            没有重复代码
            整型的除法:浮点数(小数)
            print()
            input 获取到的都是字符串
    

    第九题:提示用户输入的麻花藤. 判断用户输入的是否正确. 如果对, 提示真聪明, 如果不对, 提示用户输入错误

    • 答案:

      user_name = input("请您输入一下麻花藤:")
      if user_name == "麻花藤":
          print("你真的好聪明哦!")
      elif user_name != "麻花藤":
          print("用户输入错误!")
      
    • 截图:

第十题:用户输入一个月份.然后判断月份是多少月.根据不同的月份,打印出不用的饮食(根据个人习惯和老家习惯随意编写)

  • 答案:

    mouth = input("请您输入一个月份:")
    print("您输入的月份是:",mouth)
    if mouth >= "1" and mouth < "4" :
        print("此时,你处在陕西春天,吃些羊肉泡比较好!")
    elif mouth >= "4" and mouth < "7":
        print("此时,你处在陕西夏天,吃些老潼关夹馍!")
    elif mouth >= "7" and mouth < "10":
        print("此时,你处在陕西秋天,吃些大荔冬枣和带把肘子!")
    elif mouth >= "10" and mouth <= "12":
        print("此时,你处在陕西冬天,经常下大雪,点外卖吧孩纸!")
    
    
    • 截图:

第十一题:用户输入一个分数.根据分数来判断用户考试成绩的输出不同的档次

=90 A
=80 B
=70 C
=60 D
< 60 不及格
  • 答案:

    grade = int(input("请输入您的分数:"))
    if grade >= 90:
        print("恭喜您,荣获A,学习非常优秀")
    elif grade >= 80 and grade < 90:
        print("小伙子,继续努力,获得B级")
    elif grade >= 70 and grade < 80:
        print("你获得C级,小伙子。加油,你会进步的!")
    elif grade >= 60 and grade < 70:
        print("你刚及格,D级,好好学吧,父母挣钱不容易!")
    elif grade < 60:
        print("你的成绩不及格,后期多努力一点,加油,你是最棒的!")
    
    • 截图:

老师,您批阅作业辛苦了!!!

终生名言:业精于勤,荒于嬉,行成于思,毁于随!

Guess you like

Origin www.cnblogs.com/ghh520/p/11469336.html