1、1-10中3和5倍数的数之和
# -*- coading:utf-8 -*-
'''
sum
2018-03-27
ping
'''
nums = []
for i in range(1,10):
if i%3 == 0 or i%5 == 0:
nums.append(i)
print(nums)
print(sum(nums))
2、简易的登陆注册
# -*- coding:utf-8 -*-
'''
this is a test code!
2018-02-24
docstring
'''
print('please input\
username :') #get user input
a=input()
print('password :')
b=input()
a=str(a)
b=int(b)
print('您的用户名为:',a)
print('密码为:',b)
print('注册成功!')
3、冰雹序列
# -*- coading:utf-8 -*-
'''
ice list
2018-3-25
ping
'''
num = input('please input a number:')
print(num)
num = int(num)
if num%2 == 0: #判断奇偶数
num = num/2
print(int(num))
else:
num = num * 3 + 1
print(int(num))
i =num
while i!=1: #循环到数字1结束
if i%2 == 0:
i = i/2
else:
i = i * 3 + 1
print(int(i))
4、计算器
# -*- coading:utf-8 -*-
'''
ping
dict
2018-04-01
'''
x = int(input('first:'))
o = input('operater:')
y = int(input('second:'))
operator = {
'+':x+y,
'-':x-y,
'*':x*y,
'/':x/y
}
result = operator.get(o,'please input +|-|*|/')
print(result)