zoukankan      html  css  js  c++  java
  • day1

    1.简述变量命名规范。

    •    1.只能是字母、数字、下划线任意组合。
    •    2.不能以数字开头。
    •    3.不能使用Python关键字。
    •    4.命名不能太长。
    •    5.不能使用中文命名。
    •    6.命名要具有可描述性。

    2.name=input(">>>"),name变量是什么数据类型?

       字符串;str

    name=input(">>>")
    print(type(name))
    

    3.if条件语句的基本结构?

    if {条件}  {结果}

    1.   if  ......:
    2. if   else:
    3.   if elif elif  .........
    4. if elif elif else
    5. if嵌套if

    4.用print打印出下⾯面内容: ⽂能提笔安天下, 武能上⻢马定乾坤. ⼼心存谋略略何⼈人胜, 古今英雄唯是君.

    print('''
             ⽂文能提笔安天下, 
             武能上⻢马定乾坤. 
             ⼼心存谋略略何⼈人胜, 
              古今英雄唯是君.''')
    

    5.利用if语句写出猜大小的游戏。

    设定一个理想数字比如:66,让用户输入数字,如果比66大,则显示猜测 的结果⼤了;如果比66小,则显示猜测的结果小了;只有等于66,显示猜测结果 正确。 

    num=int(input("please input  the number you  guess: "))
    if num >66:
                print("The number you guess is bigger")
    elif num <66:
                print("The number you guess is samller")
    else:
                print("congratulations!!")
    

    6.提⽰⽤用户输⼊入他的年年龄, 程序进⾏行行判断. 

    如果⼩小于10, 提⽰⼩小屁孩, 如果⼤大于10, ⼩小于 20, 提⽰⻘青春期叛逆的⼩小屁孩. 如果⼤大于20, ⼩小于30. 提⽰开始定性, 开始混社会的⼩小 屁孩⼉儿, 如果⼤大于30, ⼩小于 40. 提⽰看⽼老老⼤大不不⼩小了了, 赶紧结婚⼩小屁孩⼉儿. 如果⼤大于40, ⼩小 于50. 提⽰家⾥里里有个 不不听话的⼩小屁孩⼉儿. 如果⼤大于50, ⼩小于60. 提⽰⾃自⼰己⻢马上变成不不听 话的⽼老老屁孩⼉儿. 如果⼤大于60, ⼩小于70. 提⽰活着还不不错的⽼老老屁孩⼉儿. 如果⼤大于70, ⼩小于 90. 提⽰⼈人 ⽣生就快结束了了的⼀一个⽼老老屁孩⼉儿. 如果⼤大于90以上. 提⽰. 再⻅见了了这个世界.

    age=int(input("please enter your age:  "))
    if age<10:
         print("wimpy kid!")
    elif  age>10 and  age<=20 :
         print("rebellious adolescent child!")
    elif  age>20  and age <=30:
         print(" people enter the society ")
    elif  age>30 and age <=40:
         print("it is time to marry and have a baby.")  
    elif  age>40 and age <=50:
         print("I have a naughty child")
    elif  age>50 and age <=60:
         print("be about to be a naughty oldboy")
    elif  age>60 and age <=70:
         print("I am a  living well  oldboy")
    elif  age>70 and  age<=90:
         print("a man that life is ending")
    else:
          print("goodbye,my world!!!")
    

    7.单行注释以及多行注释?

       单行注释:#   注释后该行将不再执行。

       多行注释:三个单引号  '''或  三个双引号  """   用于注释多行或段落,注释后不再执行。

    8.提⽰⽤户输⼊⿇花藤. 判断⽤户输⼊的对不对. 如果对, 提⽰真聪明, 如果不 对, 提⽰你 是傻逼么?

    str=input("please input 麻花藤: ")
    str1="麻花藤"
    if str == str1:
        print("you are clever!")
    else:
        print("Are you an idiot?")
    

    9.用户输⼊⼀个⽉月份. 然后判断月份是多少月. 根据不同的⽉份, 打印出不同的 饮⾷(根据个⼈人习惯和⽼老老家习惯随意编写)  

    mon=int(input("please input a month:  "))
    if mon <4 :
           print("rice ,my love!")
    elif mon >=4 and mon <9:
           print("time to eat  ice cream")
    else :
           print("I need to buy a down coat!")
    

    10.⽤户输入⼀个分数. 根据分数来判断用户考试成绩的档次,  

        >=90        A             >=80        B             >=70        C             >=60        D             <  60        E

    score=int(input("please input a score:  "))
    if score >70:
    	if  score <=80:
    		print("you get a C")
    	elif score >80 and score <=90:
    		print("you get a B!")
    	else:
    		print("you get a A!!")
    else:
    	if score>=60:
    		print("you  get a D.")
    	else:
    		print("you get a E!")
    

      

  • 相关阅读:
    八大排序
    链表的合并
    记录B站yxc的背包九讲相关代码
    C++中多态实现
    YOLOV4所用到的一些tricks
    C++中的string 和 stringstream 的知识
    博客园中插入视频
    博客园中插入网页
    面试前必须要知道的【可重入锁 自旋锁】
    面试前必须要知道的【乐观锁 悲观锁】
  • 原文地址:https://www.cnblogs.com/andyyangpython/p/10450453.html
Copyright © 2011-2022 走看看