成长是一场和自己的比赛,不要担心别人会做得比你好,你只需要每天都做得比前一天好就可以了。
import numpy as np
def function():
a = float(input('==>'))
b = float(input('==>'))
c = float(input('==>'))
dr = b * b -4 *a *c
r1 = (-b + np.sqrt(dr) ) / 2 *a
r2 = (-b - np.sqrt(dr) ) / 2 *a
if dr > 0 :
print('The roots are %f and %f'%(r1,r2))
elif dr == 0:
print('The root is %f'%r1)
else:
print('The equation has no real roots')
function()
import random
def suma():
ran1 = random.randint(1,100)
ran2 = random.randint(1,100)
print(ran1,ran2)
sum1 = int(input('输入两个数的和:'))
ran = ran1 + ran2
if ran == sum1:
print('True')
else:
print('False')
suma()
def function():
list = []
num1 = int(input('==>'))
num2 = int(input('==>'))
num3 = int(input('==>'))
list.append(num1)
list.append(num2)
list.append(num3)
list.sort()
print(list)
function()
def function():
kg1,money1 = eval(input('==>'))
kg2,money2 = eval(input('==>'))
if money1 > money2:
print('第2袋比较好')
else:
print('第1袋比较好')
function()
import random
def function():
ran = random.randint(0,1)
print(ran)
num = int(input('用户猜测(0代表正面,1代表反面):'))
if ran == num:
print('正确')
else:
print('错误')
function()
import random
con = random.randint(0,2)
print(con)
user = int(input('0:石头,1:剪刀,2:布'))
if con == user:
print("平局")
else:
if con == 0 and user == 1:
print("电脑赢了")
elif con == 1 and user == 2:
print("电脑赢了")
elif con == 2 and user == 0:
print("电脑赢了")
else:
print("玩家赢了")
def date():
year = int(input('年'))
mouse = int(input('月'))
list1 = [1,3,5,7,8,10,12]
list2 = [4,6,9,11]
if mouse in list1:
print('31天')
elif mouse in list2:
print('30')
else:
if year % 400 ==0:
print('29天')
else:
print('28天')
date()
def function():
year = int(input('年'))
mounth = int(input('月'))
data = int(input('天'))
k = year % 100
j = year / 100
h = (data + (26 * (mounth + 1) / 10) + k + (k / 4) +(j/4) + 5 * j ) % 7
print('这一天是星期%d'%h)
function()
def function():
num = input('输入一个三位数:')
gw = num[2]
bw = num[0]
if gw == bw :
print('%r是回文素数'%num)
else:
print('%r不是回文素数'%num)
function()
def zhuchang():
a,b,c = eval(input('Enter three edges:'))
if a + b > c and a + c > b and b +c > a:
print("合法的")
else:
print('非法的')
zhuchang()
def dat(a):
if a == 0:
print('星期日')
elif a== 1:
print('星期一')
elif a== 2:
print('星期二')
elif a== 3:
print('星期三')
elif a== 4:
print('星期四')
elif a== 5:
print('星期五')
else:
print('星期六')
def str():
b = int(input('输入月份'))
c = int(input('今天之后到未来的某天'))
a = (b + c) % 7
dat(a)
str()
import random
def fun():
li = ['♠','♦','♥','♣']
b= random.randint(0,3)
lis = li[b]
val = random.randint(1,13)
print('你抽中的是%r%r'%(lis,val))
fun()