sum=0
for i in range(1,101):
sum+=i
print(sum)
n= int(input('请输入一个数:'))
n=n*n
if n< 50:
print('平方和小于50,退出')
else:
print(n)
a= int(input('请输入第一个数:'))
b= int(input('请输入第二个数:'))
print(a,b)
a,b=b,a
print(a,b)
a= int(input('请输入第一个数:'))
b= int(input('请输入第二个数:'))
if a > b:
print('a比b大')
else:
print('b比a大')
MAX = lambda x, y: (x > y) * x + (x < y) * y
MIN = lambda x, y: (x > y) * y + (x < y) * x
a = 10
b = 20
print('The largar one is %d' % MAX(a, b))
print ('The lower one is %d' % MIN(a, b))
import random
print(random.uniform(1,100))
a=3
b=7
print('a & b = %d' % b)
b &= 7
print('a & b = %d' % b)
b = a | 3
print ('a | b is %d' % b)
b |= 7
print ('a | b is %d' % b)
b = a ^ 3
print ('The a ^ 3 = %d' % b)
b ^= 7
print ('The a ^ b = %d' % b)
from tkinter import *
canvas = Canvas(width=800, height=600, bg='yellow')
canvas.pack(expand=YES, fill=BOTH)
k = 1
j = 1
for i in range(0, 26):
canvas.create_oval(310 - k, 250 - k, 310 + k, 250 + k, width=1)
k += j
j += 0.3
mainloop()
rom tkinter import *
canvas = Canvas(width=300, height=300, bg='green')
canvas.pack(expand=YES, fill=BOTH)
x0 = 263
y0 = 263
y1 = 275
x1 = 275
for i in range(19):
canvas.create_line(x0, y0, x0, y1, width=1, fill='red')
x0 = x0 - 5
y0 = y0 - 5
x1 = x1 + 5
y1 = y1 + 5
x0 = 263
y1 = 275
y0 = 263
for i in range(21):
canvas.create_line(x0, y0, x0, y1, fill='red')
x0 += 5
y0 += 5
y1 += 5
mainloop()
from tkinter import *
root = Tk()
root.title('Canvas')
canvas = Canvas(root, width=400, height=400, bg='yellow')
x0 = 263
y0 = 263
y1 = 275
x1 = 275
for i in range(19):
canvas.create_rectangle(x0, y0, x1, y1)
x0 -= 5
y0 -= 5
x1 += 5
y1 += 5
canvas.pack()
root.mainloop()