第1关:if分支入门※

# 第一题

month = int(input())
# 31天的月份:1~7之间的奇数月、8~12之间的偶数月
# 如果是31天的月份输出yes
####### begin #######
#if month == 1 or month == 1 or month == 1 or month == 1
if (month <=7 and month %2 !=0 ) or (month>=8 and month %2 == 0):
    print('yes')
else:
    print('no')

####### end #########
# 如果不是31天的月份,输出no
####### begin #######
####### end #########
print('\n***********************\n')

#第二题
# 从测试集得到风速
velocity = int(input())
# 默认是0级
rank = 0
# 如果风速在74到95之间,输出1
####### begin #######
if velocity >= 74 and velocity <=95:
    rank = 1
####### end #########
# 如果风速在96到110之间,输出2
####### begin #######
if velocity >= 96 and velocity <= 110:
    rank = 2
####### end #########
# 如果风速在111到130之间,输出3
####### begin #######
if velocity >= 111 and velocity <= 130:
    rank = 3
####### end #########
# 如果风速在131到154之间,输出4
####### begin #######
if velocity >= 131 and velocity <= 154:
    rank = 4
####### end #########
# 如果风速大于155,输出5
####### begin #######
if velocity > 155:
    rank = 5
####### end #########
print(rank)

第2关:while循环分支入门※

from math import *

i = 1 # 当前计算的值
s = 0 # 计算出来的和
# 第一题
########### begin ##########
while i<1000:
# 请在此输入循环控制语句

######### end     ####
    s = s + i ** 2
    i = i + 2

print(s)

########## 第二题 ##############
x = int(input())

if x<0:
    print('无实数解')
else:
    g = x/2
    #######begin##############
    # 请输入循环控制语句
    while abs(x-g*g)>(1e-6):
    #######end#################
        g = (g+x/g)/2
    print(g)

 

Logo

GitCode AI社区是一款由 GitCode 团队打造的智能助手,AI大模型社区、提供国内外头部大模型及数据集服务。

更多推荐