import time
import linecache
import random
import os
defmain()
:while
true
:try
("- -"*20
)# 一言
file_yi = r'e:\python\book\yi.txt'
num_yi = random.randint(1,
300)
defline
(file
, num)
: a = linecache.getline(
file
, num)
.strip(
(, end='')
(time.strftime(
'%y-%m-%d %h:%m'
, time.localtime(time.time())
("- -"*20
("一言: "
+ a)
line(file_yi, num_yi)
("- -"*20
("1.手機充值\n"
"2.根據父母身高**兒子身高\n"
"3.根據總步數計算消耗的熱量\n"
"4.猜謎語\n"
"5.逢七拍腿\n"
"6.清屏\n"
"0.退出程式"
("- -"*20
) choose =
int(
input
("輸入你的選擇:"))
("你選擇了:%d"
%choose)
if choose in[1
,2,3
,4,5
,6,7
,0]:
if choose ==1:
mobile(
)elif choose ==2:
height(
)elif choose ==3:
heat(
)elif choose ==4:
riddle(
)elif choose ==5:
number_7(
)elif choose ==6:
os.system(
'color a'
) os.system(
'cls'
)elif choose ==7:
os.system(
'color a'
) os.system(
'cls'
("* * * * *啟動裡模式* * * * *"
) os.system(
'e:\python\\book\\123.bat'
)elif choose ==0:
("退出成功"
)break
else
("輸入錯誤,重新輸入"
)except valueerror:
("輸入錯誤重新輸入"
)except exception as c:
("未知錯誤%s"
% c)
#1.手機充值
defmobile()
: of =
float
(input
("輸入充值金額:"))
("您以成功充值%.2f元"
%of)
#2.根據父母身高**兒子身高
defheight()
: fheight =
float
(input
("父親身高(cm):"))
mheight =
float
(input
("母親身高(cm):"))
eheight =
(fheight+mheight)
*0.54
("**兒子身高為:%.2f(cm)"
%eheight)
#3.根據總步數計算消耗的熱量
defheat()
: count =
int(
input
("輸入步數:"))
calories =count*
28 kcalories =count*28/
100print
("今天走了%d步\n"
"消耗%d卡路里\n"
"(%d千卡)"
%(count,calories,kcalories)
)#4.猜謎語
defriddle()
:while
true
("今有物不知其數,三三數之剩二,五五數之剩三,七七數之剩二,問幾何?"
) number =
int(
input
("輸入謎底:"))
if number%3==
2and number%5==
3and number%7==
2:print
("你輸入:%d,\n恭喜答對了\n"
%number)
break
elif number>
100:
("- - - - 開啟自助解答模式 - - - -"
)for number in
range
(101):
("正在嘗試第%d次"
%number)
if number %3==
2and number %5==
3and number %7==
2:print
("你輸入:%d,\n恭喜答對了\n"
% number)
("- - - - 自助解答模式結束 - - - -"
)break
else
("你輸入:%d,\n很遺憾請再接再厲\n"
%number)
#5.逢七拍腿
defnumber_7()
: numlist =
number =
int(
input
("輸入你想要計算的個數:"))
for number in
range
(number+1)
:if number%7==
0and number !=0:
elif
str(number)
.endswith(
"7")
("在這%d個數中被七和末尾是七的數一共有%d個"
%(number,
len(numlist)))
("以下數字是被七和末尾是七的數:\n%s"
%numlist)
if __name__ ==
'__main__'
: main(
)#number_7()
verilog入門小結
1 verilog hdl語言過程中關於三種常用賦值語句 阻塞賦值語句,相當於序列語句,即所有該型別語句在所在模組內按順序執行。常用於組合邏輯。非阻塞賦值語句,相當於並行語句,當該語句所在模組結束時,所有帶 的語句同時執行。常用於時序邏輯 暫存器 2 inout outpunt inout 等本身預...
Python入門小結
2017新年伊始,花了一點時間,把python的基礎語法學了一遍。有點趕,敲 的時間越來越少,腦子中的想法越來越多,真矛盾。2017,努力轉型成為乙個強大的程式設計師!一,python語言相比c c 較為簡單,沒有那麼多的規矩。不需要用花括號表示語句塊,而是用縮排代表。比如 if a b print...
bash入門小結
本文總結自 shell從入門到精通 新建指令碼文字 test1.sh bin bash echo what s your name?read person echo hello,person 然後依次在命令列輸入 cd home zhangjin zhangjinming chmod x test....