Cov txheej txheem:
- Kauj Ruam 1: Hais ib yam dab tsi
- Kauj Ruam 2: Nov Yog Qhov Loopy Me…
- Kauj Ruam 3: Tawm tswv yim thiab tso tawm
- Kauj Ruam 4: Yog los ntawm Rudya ----- tsis Yog Tsis Yog! Nws yog Python U Dimwit
- Kauj Ruam 5: Pib ntawm Easygui
- Kauj Ruam 6: Dab Tsi Ntxiv?
Video: Python Tutorial: 6 Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:28
Nyob zoo! Zoo siab txais tos rau kuv cov lus qhia thib ob thiab qhov no yuav yog qhov pib ntawm nab hab sej.
Hauv cov lus qhia no, Kuv yuav qhia koj cov hauv paus ntawm cov loops, cov tswv yim thiab cov khoom tso tawm, kom lub khoos phis tawj hais ib yam dab tsi, yog cov lus hais thiab qhov txawv. Hauv qhov kawg peb yuav siv GUIs lossis cov duab siv sib cuam tshuam nrog cov cuab yeej hu ua easygui.
Ib zaug ntxiv, tawm lus hais txog yuav ua li cas kuv yuav tsum txhim kho thiab cov lus nug ntawm cov khoom koj tsis nkag siab
muaj kev lom zem!
Kauj Ruam 1: Hais ib yam dab tsi
Hauv theem no, peb yuav kawm paub ua kom nab nab hais dab tsi. yooj yim heev txhua yam koj yuav tsum ntaus ntawv yog yam koj xav hais, tom qab ntawd muab qhov no nyob ib puag ncig nws. print ('') cov. piv txwv li luam tawm ('nyob zoo ntiaj teb'). yog tias koj tab tom siv nab hab sej 2 koj yuav sau cov ntawv "nyob zoo ntiaj teb" ntaus qhov no rau hauv lub qhov rais plhaub - tus uas tawm los thiab nias nkag mus.
koj mus! koj thawj txoj haujlwm
Kauj Ruam 2: Nov Yog Qhov Loopy Me…
ua ntej tshaj plaws, nyem Ctrl+N uas yuav coj koj mus rau cov ntawv tshiab. txuag nws raws li loops.py tus.py ntsis qhia tias qhov no yog cov ntaub ntawv sej. qhov no yog thawj hom voj.
rau kuv hauv ntau (1, 101):
luam tawm (kuv)
qhov no yuav mus zoo li no
1
2
3
4
5
6
7
100
qhov sib txawv, kuv, yuav cia li ntxiv ib qho txhua lub sijhawm nws loops siab txawm hais tias, nws tsis luam tawm 101.
nov yog lwm lub voj
kuv = 1
thaum kuv <100:
kuv = i+1
luam tawm (kuv)
qhov no zoo sib xws rau saum toj kawg nkaus. peb hu rau sab saum toj ib qho rau lub voj thiab hauv qab ib lub voj.
lub voj thaum suav nrog 100 yog li tsis tas yuav ua thaum kuv <101.
Kauj Ruam 3: Tawm tswv yim thiab tso tawm
txoj haujlwm no yuav ua rau lub khoos phis tawj nug koj ib yam thiab teb rau lo lus teb.
qhov no yog ib qho piv txwv
f = input ('dab tsi yog koj lub npe') <----------- teeb tsa qhov sib txawv thiab qhia txog kev nkag
print ('nyob zoo', f) <------------------------- luam tawm qhov sib txawv uas tau nkag los ntawm tus neeg siv nrog nyob zoo rau pem hauv ntej
cov zis yuav tsum yog ib yam zoo li no:
>> koj lub npe hu ua Larry
>> nyob zoo Larry
raws li koj tuaj yeem pom cov tswv yim tsis zoo heev. yog tias koj xav tau chaw, tso qhov kawg ntawm thawj kab:
f = input ('koj lub npe yog dab tsi')
yog tias koj xav kom nws nug koj hnub nyoog lossis pes tsawg mars tuav koj muaj, ua qhov no:
f = int (input ('koj muaj hnub nyoog li cas'))
yog tias nws yog tus lej lej, ua:
f = float (input ('enter a decimal number'))
koj nyob li cas
Kauj Ruam 4: Yog los ntawm Rudya ----- tsis Yog Tsis Yog! Nws yog Python U Dimwit
yog tias nqe lus feem ntau siv los sib piv 2 cov hlua lossis cov lej.
nws feem ntau tuaj tom qab kev tawm tswv yim
ntaus qhov program hauv daim duab thiab koj yuav tuaj yeem pom muaj txiaj ntsig yog tias tuaj yeem yog thiab qee yam uas koj tsis xav tau …
ib txwm ntaus:
yog*ib yam*, =,! =, =*lwm yam*:
print (*ib yam*'yog dab tsi tshaj'*lwm yam*)
Kauj Ruam 5: Pib ntawm Easygui
easygui yog tus qauv uas yuav tsum tau rub tawm.
rub nws yog tias koj tsis muaj nws ces sim qhov program no.
ntshuam easygui
easygui.msgbox ('nyob zoo lub ntiaj teb')
nws yuav tsum tuaj nrog qee yam zoo li hauv daim duab.
Kauj Ruam 6: Dab Tsi Ntxiv?
yog li ntawd nws yog tam sim no.
khaws lub qhov muag qhib, kuv yuav ua lwm yam kev qhia xws li windows batch thiab lwm yam lus. nyob zoo!
ua tau zoo tiag tiag uas yog ntau yam los kawm!
sib nrug los ntawm cov ntawv qhia uas kuv tau sau, muaj ntau qhov kev qhia ntawm ntau yam lus. yog tias koj xav tau txais pdf nrog cov ntsiab lus ntau ntxiv, kuv pom zoo kom Nyob Zoo Phau Ntawv Ntiaj Teb 2 uas muaj nyob hauv is taws nem - tsuas yog tshawb nws.
yog tias koj tsis tau tswj kom nruab easygui thiab xav tau, rub qhov txuas no:
Kuv kuj tau tsim kuv tus kheej lub npe hu ua PyCal uas cia koj xam cov khoom nrog cov qauv nyuaj xws li Pythagoras 'theorem thiab thaj tsam ntawm lub voj voog.
Pom zoo:
Arduino Tsheb Rov Qab Chaw Nres Tsheb Ceeb Toom - Cov Kauj Ruam ntawm Kauj Ruam: 4 Kauj Ruam
Arduino Tsheb Rov Qab Chaw Nres Tsheb Ceeb Toom | Cov kauj ruam ib kauj ruam: Hauv txoj haujlwm no, kuv yuav tsim qhov yooj yim Arduino Tsheb Rov Qab Tsheb Nres Tsheb Nres Sensor Siv Arduino UNO thiab HC-SR04 Ultrasonic Sensor. Qhov no Arduino raws Lub Tsheb Rov Qab ceeb toom tuaj yeem siv rau Kev Tshawb Fawb Txog Tus Kheej, Robot Ranging thiab lwm yam
Raspberry Pi - PCA9536 Cov tswv yim/tso tawm Expander Python Tutorial: 4 Cov Kauj Ruam
Raspberry Pi-PCA9536 Cov tswv yim/tso tawm Expander Python Tutorial: PCA9536 yog 8-pin CMOS ntaus ntawv uas muab 4 khoom ntawm Lub Hom Phiaj Dav Dav Nkag Mus Los/Tso Tawm (GPIO) nthuav dav rau I2C-npav/SMBus daim ntawv thov. Nws suav nrog 4-ntsis Kev teeb tsa sau npe los ua haujlwm lub hom phiaj ntawm kev tawm tswv yim lossis xaiv tawm, 4-ntsis
Tsev Automation Kauj Ruam ntawm Kauj Ruam Siv Wemos D1 Mini Nrog PCB Tsim: 4 Kauj Ruam
Tsev Automation Kauj Ruam Ib Leeg Siv Wemos D1 Mini Nrog PCB Tsim: Tsev Automation Kauj Ruam los ntawm Kauj Ruam siv Wemos D1 Mini nrog PCB Tsim cov tub ntxhais kawm ntawv qib siab. Tom qab ntawd ib tus ntawm peb cov tswv cuab tuaj
RC Taug Qab Neeg Hlau Siv Arduino - Kauj Ruam Ib kauj ruam: 3 Kauj Ruam
RC Tracked Robot Siv Arduino - Kauj Ruam Ib Nrab: Hav guys, Kuv rov qab los nrog lwm tus neeg hlau txias chassis los ntawm BangGood. Vam tias koj tau dhau los ntawm peb cov phiaj xwm yav dhau los - Spinel Crux V1 - Tus Cwj Pwm Tswj Tus Neeg Hlau, Spinel Crux L2 - Arduino Xaiv thiab Muab Neeg Hlau nrog Robotic caj npab thiab Badland Braw
Python Tutorial No.1: 5 Cov Kauj Ruam
Python Tutorial No.1: Nov yog Python tutorial ua nrog tus pib ua tiav hauv siab. Qhia luv luv rau Python yuav ua rau muab kev nkag siab yooj yim rau koj txog keeb kwm thiab nws yog dab tsi, ua ntej peb txav mus rau cov lus qhia. Python yog dab tsi Tau txais los ntawm www.python.org:Python