Cov txheej txheem:
- Kauj ruam 1: Ntau ntawm Easygui
- Kauj Ruam 2: Kev txiav txim siab
- Kauj Ruam 3: Kev Ua Haujlwm
- Kauj Ruam 4: Cov Hom Phiaj
- Kauj ruam 5: Cov lus pom
- Kauj Ruam 6: Cov Qauv
- Kauj Ruam 7: Dab Tsi Ntxiv?
Video: Nab hab sej rau Tsis Yog-Pib Pib Pib: 7 Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:28
Nyob zoo, lub sijhawm kawg, yog tias koj tau ua tib zoo saib, peb tau kov ntawm qhov pib ntawm nab nab - luam tawm, thaum thiab rau lub voj, cov tswv yim & tso tawm, yog, thiab pib ntawm easygui. kuj tseem faib dawb ntawm easygui thiab pycal-kuv tus kheej cov qauv.
qhov kev qhia no yuav npog:
ntau ntawm easygui
kev txiav txim siab
kev ua haujlwm
khoom
lus
thiab modules
-ntau heev!
yog tias koj xav nkag mus rau kuv cov lus qhia zaum kawg ntawm cov hauv paus ntawm nab nab, thov nyem qhov no.
btw, tabbing ploj mus tsis raug hauv kev tshaj tawm, yog li nyem cov duab hauv txhua ntu kom pom tias qhov haujlwm yuav tsum zoo li cas.
Kauj ruam 1: Ntau ntawm Easygui
rov qab:
txoj hauv kev los tso saib lub thawv lus hauv easygui yog:
******************************************************
ntshuam easygui
easygui.msgbox ("nyob zoo ntiaj teb")
******************************************************
siv khawm
ntawm no yog qhov program uas nug txog koj nyiam xim.
*******************************************************
ntshuam easygui
xim = easygui.buttonbox ("xaiv koj nyiam xim", xaiv = ['xiav', 'liab', 'ntsuab'])
easygui.msgbox ("koj khaws" + xim)
*********************************************************
siv lub thawv xaiv
yooj yim - tsuas yog hloov lub.buttonbox rau.choicebox.
siv enterbox
rho tawm kab 2-3 ntawm koj lub programbox thiab hloov nws mus:
xim = easygui.enterbox ("xaiv koj nyiam xim")
teeb tsa lub neej ntawd
txoj hauv kev los teeb tsa lub neej ntawd yog ntxiv kab hauv qab ntawm qhov program nkag mus zoo li no:
xim = easygui.enterbox ("xaiv koj nyiam xim", default = 'xiav')
Txoj hauv kev no yuav muaj lo lus tsis raug hauv lub npov ntawv - koj tuaj yeem tshem nws thiab sau koj tus kheej rau hauv, tab sis koj tsuas tuaj yeem nias sau yog tias koj nyiam xim yog lub neej ntawd.
Kauj Ruam 2: Kev txiav txim siab
peb tau ua qee yam zoo sib xws rau qhov no - yog nqe lus. tam sim no peb yuav txiav txim siab kho lub computer.
ntaus qhov program no rau hauv qhov chaws tshiab qhov chaws tsis txhob ntaus "<---" s thiab cov ntawv tom qab nws.
*************************************************
hnub nyoog = int (input ("nkag hnub nyoog koj:"))
xyoo = int (cov tswv yim ("nkag mus rau qib koj:"))
yog hnub nyoog> = 12 thiab xyoo> = 7: <------------------- thiab txiav txim siab tias tsuas yog ob nqe lus muaj tseeb, nws tuaj yeem txuas ntxiv.
print ("koj tuaj yeem ua si qhov game no.")
lwm tus: <--------------------- lwm qhov ua kom ntseeg tau tias yog cov nqe lus ntawm yog tias tsis tau siv, cov cai hauv lwm qhov yuav ua mus ntxiv.
print ("koj ua tsis tau qhov game no.")
****************************************************
lub luag haujlwm tom ntej yog elif. elif luv rau lwm yog tias. elif txhais tau tias koj tuaj yeem thov ntau qib rau txoj haujlwm.
lwm tus
elif [yog tias tsis tseeb mus rau lwm qhov]
elif [yog tias tsis tseeb mus rau qhov txuas ntxiv mus]
elif [yog tias tsis yog, mus rau qhov txuas ntxiv mus]
yog [yog tias tsis muaj tseeb mus rau elif]
Kauj Ruam 3: Kev Ua Haujlwm
kev ua haujlwm tuaj yeem txuag koj los ntawm kev sau kab (qee zaum ntau kab) ntau thiab ntau dua txhua lub sijhawm koj xav tau siv nws. kom zam qhov no, koj xav tau qhov def () muaj nuj nqi. sau qhov no hauv qhov chaws qhov rai:
*************************************
def printmyadress (): cov
luam tawm ('Larry Zhang')
luam tawm ('32 Holley Crescent ')
luam tawm ('Oxford, Oxfordshire')
print ('OX3 8AW')
printmyadress ()
printmyadress ()
printmyadress ()
printmyadress ()
****************************************
plaub lub printmyadresses yuav luam kab hauv "def printmyadress ():" plaub zaug yam tsis tau koj ntaus nws tawm plaub zaug.
Kauj Ruam 4: Cov Hom Phiaj
koj yuav piav txog yam khoom li cas? zoo yog qhov peb yuav ua. peb tab tom ntaus ib qho program uas piav qhia txog lub tsheb, tom qab ntawd, peb yuav sim nws nrog luam (). rau qhov no, peb xav tau txoj haujlwm tshiab - chav kawm. chav kawm zoo li mega def, uas suav nrog ntau qhov defs hauv nws. ntaus tawm cov kab hauv qab no rau hauv qhov chaws tshiab qhov rai:
************************************************
tsheb chav kawm:
def tsav (tus kheej):
yog self.direction == ("rau pem hauv ntej"):
self.direction = ("pem hauv ntej")
yog self.fuel <= 0:
print ("tsis muaj roj seem!")
**************************************************
tam sim no cia peb sim qhov program, ntxiv cov kab hauv qab no mus rau qhov kawg:
****************************************
c = tsheb () c.direction = ("rau pem hauv ntej")
print ("kuv lub tsheb yuav mus"+c.direction)
c.drive ()
print ("kuv lub tsheb tab tom ntsib"+c.direction)
*********************************************
cov zis yuav tsum zoo li no:
================================== RESTART =============== ====================
kuv lub tsheb mus tom ntej
kuv lub tsheb tig xub ntiag
>>
tam sim no peb yuav teeb tsa qee qhov kev hloov pauv nrog _init_.
ntxiv cov kab no ua ntej def drive (tus kheej):
********************************************
def _init _ (tus kheej, kev taw qhia, roj):
tus kheej.fuel = (roj)
self.direction = kev taw qhia
*********************************************
tam sim no, cia saib tag nrho chav kawm nrog kev xeem:
*********************************************
chav kawm tsheb: <----------- cia nab nab paub tias peb tab tom ua chav kawm def _init _ (tus kheej, kev qhia, roj): <--------------- -initializing qhov pib hloov pauv
tus kheej.fuel = (roj)
self.direction = (kev taw qhia)
def tsav (tus kheej):
self.fuel- = 1 <------------------- tshem tawm ib litre roj
yog self.direction == ("rau pem hauv ntej"):
self.direction = ("pem hauv ntej")
yog self.fuel <= 0:
print ("tsis muaj roj seem!")
c = tsheb ("rau pem hauv ntej", int (2)) <-------------- teeb tsa cov roj thiab cov lus qhia.
print ("kuv lub tsheb yuav mus"+c.direction)
c.drive ()
print ("kuv lub tsheb tab tom ntsib"+c.direction)
print ("kuv muaj", c.fuel, "litres sab laug.")
c.drive ()
print ("kuv lub tsheb tab tom ntsib"+c.direction)
print ("kuv muaj", c.fuel, "litres sab laug.")
*********************************************
pev! qhov ntawd yog ntau yam los kawm! tsis txhob txhawj xeeb yog tias koj tsis tau txais nws thawj zaug puag ncig - kuv tsis yog! tsuas yog saib rov qab!
Kauj ruam 5: Cov lus pom
txhob txhawj! kuv tsis muab daim ntawv qhia rau koj! cov lus pom yog qee yam hauv qhov program rau cov programmer pom kom lawv paub tias lawv ua dab tsi. lawv yuav tsis khiav ntawm lub computer. ntaus kab no tawm:
***********************
#yog qhov comment
print ("qhov no tsis yog lus pom")
**********************
============================= RESTART ==================== ============== Ua tsaug
qhov no tsis yog lus saib
>>
uas yuav tsum yog koj cov zis. koj tuaj yeem tso ntau kab lus ntawm cov lus zoo li no:
#**********************************
# Nov yog yuav ua li cas sau cov lus pom
# muab tus hash ua ntej txhua kab
#**********************************
lossis yog tias koj xav sau cov ntawv ntev dua thiab tsis txhob muab hash ua ntej txhua kab, koj tuaj yeem ua nws zoo li no:
"""
blahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblah
"""
triple- txoj kev.
muaj ib qho teeb meem nrog cov lus pom. cia peb hais tias koj ua haujlwm zoo li software engineer hauv tuam txhab nrog ntau tus neeg thiab koj thiab lwm tus sau ib qhov program. ces koj muab qee cov lus tso rau hauv nws. tus neeg tom ntej tuaj nrog thiab pom qhov kev zov me nyuam thiab ntxiv qee cov lus pom ntxiv tom qab ntawd tib yam tshwm sim dua thiab ntau dua. qhov kev zov me nyuam yuav xaus nrog ntau cov lus hais uas koj tsis tuaj yeem pom ib kab ntawm cov lej. qhov no ua pov thawj nyuaj heev hauv cov txheej txheem debugging. txoj hauv kev los daws qhov no yog tias koj puas tau sau ib qhov program nrog ntau tus neeg koom nrog, tsis txhob sau cov lus, tab sis sau cov ntawv.txt lossis cov ntawv lo lus uas tsuas yog koj tuaj yeem nkag mus.
Kauj Ruam 6: Cov Qauv
hauv cov kauj ruam no, kuv yuav qhia koj yuav ua li cas los ua koj tus kheej modules !!! yaj !!! Yog li … dab tsi yog qhov module raws nraim? tus qauv yog lub luag haujlwm (nco qab def ()?) uas tuaj yeem siv rau hauv lwm cov haujlwm. piv txwv li easygui yog tus qauv thiab tus qauv kuv tau tsim, hu ua PyCal kuj tseem yog tus qauv. Kuv tam sim no yuav qhia koj yuav tsim ib yam dab tsi zoo li pycal.
*************************************
#this yog tus qauv my_module
def f_to_c (f): cov
rov qab (5.0 / 9.0 * (F - 32))
*************************************
txuag nws li my_module.py.
tam sim no wb sim nws:
***************************
ntshuam my_module
my_module.f_to_c (1)
*****************************
koj yuav tsum muaj ib yam zoo li no:
================================= RESTART ================ ============== Ua tsaug
-17.22222222222222
>>
lossis koj tuaj yeem import nws zoo li no
***************************************
los ntawm kuv_module ntshuam f_to_cf_to_c (1)
***************************************
qhov no yuav ntshuam ua haujlwm tshwj xeeb.
qhia random !!!
******************************
ntshuam ntshuam
random.randint (1, 10)
******************************
koj yuav tsum muaj ib yam zoo li no:
============================= RESTART ==================== ============== Ua tsaug
5
>>
randint ntaus tus lej zauv nruab nrab ntawm tus lej faib.
lub sijhawm twg?
cia ntaus hauv qhov program tom ntej no:
**********************************
lub sij hawm ntshuam
print ("ntsib koj hauv 5 vib nas this")
sijhawm.sleep (5)
print ("nyob zoo dua")
**********************************
vaub kib
ntaus hauv qhov program hauv qab no thiab khiav:
los ntawm vaub kib ntshuam *
rau pem hauv ntej (100) <-------------- tus lej yog qhov deb.
txoj cai (90) <-------------- tus lej yog lub kaum sab xis
rau pem hauv ntej (100)
txoj cai (90)
rau pem hauv ntej (100)
txoj cai (90)
rau pem hauv ntej (100)
qhov no yuav tsum ua tiav kos ib lub xwmfab.
Kauj Ruam 7: Dab Tsi Ntxiv?
nws yog tam sim no cov txiv neej! uas yog ntau yam los kawm tshwj xeeb tshaj yog cov khoom ntu. Kuv vam tias kuv tau ua cov ntawv kom meej thiab, zoo li ib txwm, tawm lus rau yam kuv tuaj yeem ntxiv lossis txhim kho. Kuv twb tau pib xav txog cov tswv yim rau "nab nab rau cov programmer nruab nrab" yog li koj yuav tsis tau tos ntev kom paub ntau ntxiv. yog tias koj tseem tsis tuaj yeem tau txais easygui, kuv yuav muab qhov txuas rau koj ntawm no. mus rau kauj ruam 6 thiab koj yuav pom qhov rub tawm tau ntawm easygui thiab kuv tus kheej tus qauv, PyCal.
Bye Rau Tam Sim No!
Pom zoo:
DIY GPS Tracker --- Daim ntawv thov nab nab: 5 Kauj Ruam (nrog Duab)
DIY GPS Tracker --- Daim Ntawv Thov Python: Kuv tau koom nrog hauv kev caij tsheb kauj vab ob lub lis piam dhau los. Tom qab ua tiav, Kuv xav txheeb xyuas txoj kev thiab qhov nrawm kuv caij thaum lub sijhawm ntawd. Hmoov tsis, nws tsis ua tiav. Tam sim no kuv siv ESP32 los ua GPS tracker, thiab kuv yuav coj nws los sau kuv cov kev caij tsheb kauj vab
Nab hab sej txoj haujlwm - Cov paj laum uas tau koom nrog txhua hli/Kev tso nyiaj: 5 Kauj Ruam
Python Program - Sib Piv Cov Nyiaj Txiag Nrog Kev Pabcuam Ib Hlis/Deposit: Txoj haujlwm los laij cov paj laum nrog rau kev txhawb nqa txhua hli thaum kawg ntawm lub hlis. Tus lej suav los ntawm TheCalculatorSite.com: Muab cov paj laum rau tus thawj xibfwb: P (1+r/n)^(nt) Tus nqi yav tom ntej ntawm koob: PMT × (((1 + r/n)^nt - 1)/(r/n))
Ntiv nplhaib Hnub Ci Kos Npe Teardown: Kuv Ua Nws Tsis Yog Li Koj Tsis Yog Yuav Tsum Ua: 11 Kauj Ruam
Ntiv nplhaib Hnub Ci Kos Npe Teardown: Kuv Ua Nws Tsis Yog Li Koj Thiaj Li Tsis Tau: Kuv tau txais Lub Pob Ntseg Qhov Rooj, uas zoo nkauj heev. Yay rau Ring.Then Kuv tau txais Lub Nplhaib Stick-up lub koob yees duab thaum txhua qhov ncig-Thanksgiving online muag tau mus. $ 50 tawm, thiab lawv xa kuv lub Nplhaib Nifty Ring hnub ci kos npe rau dawb (tsuas yog tus nqi $ 49!). Kuv paub tseeb tias
Nab hab sej Kev Ruaj Ntseg Kev Ruaj Ntseg/Kev Txiav Txim Siab Software: 3 Kauj Ruam
Python Kev Nyab Xeeb Kev Nyab Xeeb/Kev Nyab Xeeb Kev Nyab Xeeb Software: Hauv Cov Lus Qhia Kuv yuav qhia koj li cas nrog qee qhov Python yooj yim, koj tuaj yeem khaws koj cov ntaub ntawv ruaj ntseg siv kev lag luam tus qauv AES.Requirements:- Python 3.7- PyAesCrypt library- hashlib libraryIf koj tsis muaj cov tsev qiv ntawv no, koj tuaj yeem teeb tsa tau yooj yim los ntawm
Txaus Siab Rau Koj Tus Kheej Tsuas Yog Siv 12V-rau-AC-kab Inverter rau LED Lub Teeb Hluav Taws Xob Tsis txhob Rov Ua Rau Lawv rau 12V.: 3 Cov Kauj Ruam
Txaus Siab Rau Koj Tus Kheej Tsuas Yog Siv 12V-rau-AC-kab Inverter rau LED Lub Teeb Hluav Taws Xob Tsis txhob Rewiring Lawv rau 12V: Kuv txoj kev npaj tau yooj yim. Kuv xav txiav cov phab ntsa uas siv hluav taws xob LED teeb ua ib daim ces rov txuas nws kom khiav tawm 12 volts. Lwm txoj hauv kev yog siv lub zog hloov pauv, tab sis peb txhua tus paub tias lawv tsis muaj txiaj ntsig zoo, puas yog? Txoj cai? Los yog lawv?