In [6]:
n=int(input('Please input an integer,and end with Enter.'))
i=0
j=0
def sum_(a):
total=0
for i in range(a):
j=int(input('Please input an integer,and end with Enter.'))
total=total+j
return total
print('This is the sum of these numbers:',sum_(n))
In [7]:
i=0
ms=[0]
for i in range(1000):
n=int(input('Please input an integer,and end with Enter'))
print('if you do not want to input numbers,please input out,if you want to continue inputing,please input in')
m=input()
if 'out'==m:
break
else:
continue
In [ ]:
i=0
j=0
m=0
n=0
b=0
a=0
for i in range(1000):
print('Please input an integer,and end with Enter.')
a=int(input())
m=m+a
n=n*a
if m<a and n<a*a:
break
else:
continue
In [1]:
def _sum(end):
i=0
total=1
for i in range(end):
i=i+1
total=total*i
return total
m=int(input('请输入一个整数,以回车结束'))
n=int(input('请输入一个整数,以回车结束'))
k=int(input('请输入一个整数,以回车结束'))
print('最终和是:',_sum(m)+_sum(n)+_sum(k))
In [12]:
def he(a,b,c):
i=0
total=0
i=a
j=0
for j in range(1000):
total=total+i
i=i+c
if i>b:
break
else:
continue
return total
m=int(input('请输入一个整数'))
n=int(input('请输入一个整数'))
k=int(input('请输入一个整数'))
print(he(m,n,k))
In [15]:
def end(a):
i=1
total=0
j=0
k=0
for k in range(10000000000):
if(j%2==0):
total=total-1/i
else:
total=total+1/i
i=i+2
j=j+1
if(i>=a):
break
else:
continue
return total
b=int(input('请输入一个整数,以回车结束'))
print(end(b)*4)
In [16]:
import math,random
def c_sqrt():
n=int(input('请输入一个整数,以回车键结束'))
m=int(input('请输入一个整数,以回车键结束'))
k=int(input('请输入一个整数,以回车键结束'))
i=0
total=0
num=0
for i in range(n):
num=random.randint(m,k)
total=total+num
total=math.sqrt(total/n)
print(total)
c_sqrt()
In [17]:
import math,random
def c_log():
n=int(input('请输入一个整数,以回车键结束'))
m=int(input('请输入一个整数,以回车键结束'))
k=int(input('请输入一个整数,以回车键结束'))
i=0
total=0
num=0
for i in range(n):
num=random.randint(m,k)
num=math.log10(num)
total=total+num
print(total)
c_log()
def sum_(n): number=[] total=0 for i in range(n): num=int(input("Please input an interge, end with Enter")) num.append(number) for num in number: total=total+num print(total)
a=int(input("please input an interge, end with Enter")) sum_(a)
def sum_(): number=[] total=0 num=0 for i in range(10): num=input() number.append(num) for num in number: total=total+num print(total)
sum_()
In [8]:
number=[1,2,3,4,5,6,7,8,9]
total=0
num=0
for num in number:
total+=num
print(total)
In [10]:
number=[]
min=0
num=0
i=0
n=int(input())
for i in range(n):
num=int(input())
number.append(num)
min=number[0]
for num in number:
if min<num or min==num:
min=min
else:
min=num
print(min)
In [12]:
number=[12,13,24,45,56,36,32]
num=0
l=0
n=int(input())
l=len(number)
if n<=l:
print(number[n-1])
else:
print("none")
In [14]:
import math
def cosine():
x1=int(input("请输入x1"))
x2=int(input("请输入x2"))
y1=int(input("请输入y1"))
y2=int(input("请输入y2"))
cos=(x1*x2+y1*y2)/(math.sqrt(x1*x1+y1*y1)+math.sqrt(x2*x2+y2*y2))
print(cos)
cosine()
In [18]:
a=5
b=5
c=100-a-b
count=0
for i in range(5,90):
count+=1
a+=1
c=100-a-b
if c==5:
break
for i in range(5,90):
count+=1
b+=1
c=100-a-b
if c==5:
break
print(count)