num1 = int(input("输入第一个数:"))
num2 = int(input("输入第二个数:"))
'''''
min_num = min(num1,num2) #两个数的最小值
'''''
#找出两个中较小的一个数——min
if num1 >= num2:
min = num2
else:
min = num1
for i in range(1,min+1):
if num1%i == 0 and num2%i == 0:
max = i
print('最大公约数为%d' %(max))
print('最小公倍数为%d' %((num1 * num2)/max))
x = int(input("请输入需要开根号的数字:"))
if x < 2:
print(x)
left, right = 0, x
result = 1
while abs(result - x) > 0.000001: # 不能等于0
mid = left + ((right - left)) / 2 # 要加个float,python2.x中/根据除数被除数情况来决定是否精确除法还是取整除法,python3.x中/精确除法,//整除
result = mid * mid
if mid * mid < x:
# left=mid
left = mid
else:
# right=x
right = mid
print(int(mid))
import math
a = int(input("请输入参数a的值:"))
b = int(input("请输入参数b的值:"))
c = int(input("请输入参数c的值:"))
if a == 0:
print("a为分母,不能为0")
elif (b ** 2 - 4 * a * c) < 0:
print("no real root")
elif (b ** 2 - 4 * a * c) == 0:
x1 = -b / 2 / a
print("only one repeated root,the root is %d" %(x1))
else:
x1 = -(math.sqrt((b * b - 4 * a * c) / (4 * a * a))) - (b / (2 * a))
x2 = (math.sqrt((b * b - 4 * a * c) / (4 * a * a))) - (b / (2 * a))
print("there have two real roots")
print("root1 is %d" %(x1))
print("root2 is %d" %(x2))
word = input('请输入单词:')
print(word.upper()==word or word.lower()==word or word.title()==word )
stu_pre = input('请输入学生的出勤记录').rstrip()
print (stu_pre.count('A')<=1 and stu_pre.count('LLL')==0)
move = input("请输入移动顺序:")
print(move.count('L') == move.count('R') and move.count('U') == move.count('D') )