Cov txheej txheem:

Siv Python los Kawm Tsis-Lus Askiv Keyboard Layouts: 8 Cov Kauj Ruam
Siv Python los Kawm Tsis-Lus Askiv Keyboard Layouts: 8 Cov Kauj Ruam

Video: Siv Python los Kawm Tsis-Lus Askiv Keyboard Layouts: 8 Cov Kauj Ruam

Video: Siv Python los Kawm Tsis-Lus Askiv Keyboard Layouts: 8 Cov Kauj Ruam
Video: Python! Adding a Key to a Dictionary 2024, Hlis ntuj nqeg
Anonim
Siv Python los Kawm Tsis-Lus Askiv Keyboard Layouts
Siv Python los Kawm Tsis-Lus Askiv Keyboard Layouts

Nyob zoo, Kuv yog Julien! Kuv yog tub ntxhais kawm txuj ci computer thiab hnub no kuv yuav qhia koj li cas koj tuaj yeem siv Python los qhia koj tus kheej cov keyboard txheej ntawm hom lus uas tsis yog lus Askiv. Ntau yam kev kawm lus tshwm sim online tam sim no, thiab ib yam uas tib neeg tuaj yeem tawm tsam nrog yog kawm qhov twg cov cim nyob ntawm lawv cov keyboard. Txog qhov kawg ntawm qhov kev qhia no, peb yuav muaj txoj haujlwm uas koj yuav muaj peev xwm nug koj tus kheej ntau zaus nrog rau thiab taug qab koj cov qhab nia. Txog qhov ua qauv qhia no kuv yuav siv cov tsiaj ntawv Kauslim, Hangul. Tab sis, koj tuaj yeem siv txhua yam lus uas koj nyiam tsuav nws muaj cov keyboard teeb tsa rau tus qauv WASD keyboard.

Khoom siv:

-Cov ua haujlwm hauv computer nrog Python 3 lossis tom qab hloov kho dua tshiab

Kev nkag siab yooj yim ntawm Python thiab nws cov haujlwm (phau ntawv txhais lus, rau lub voj, thaum lub voj thiab yog cov lus hais)

-Cov duab ntawm cov keyboard teeb tsa rau cov lus koj tab tom sim kawm

Kauj Ruam 1: Cov Qauv Yooj Yim

Cov qauv yooj yim
Cov qauv yooj yim

Ua ib daim ntawv Python tshiab thiab khaws nws. Pib los ntawm importing random. Tam sim no peb tuaj yeem txhais peb txoj haujlwm, uas kuv yuav hu 'ntaus ntawv'. Nco ntsoov, tias ib qho ntawm cov npe sib txawv no tuaj yeem hloov mus rau qhov koj nyiam. Hauv peb txoj haujlwm, tsim ob phau ntawv txhais lus khoob: cov tsiaj ntawv thiab tsis raug. Tom qab ntawd tsim qhov hloov pauv raug thiab muab nws rau 0.

Kauj Ruam 2: Tsim thiab Randomizing phau ntawv txhais lus

Tsev thiab Randomizing phau ntawv txhais lus
Tsev thiab Randomizing phau ntawv txhais lus

Cov phau ntawv txhais lus yuav mus qhov twg txhua tus yuam sij sib cuam tshuam thiab cov lus teb yuav muaj. Siv koj daim duab ntawm kev teeb tsa uas koj xav kawm raws li siv, thiab sau cov phau ntawv txhais lus nrog tus yam ntxwv tsis yog lus Askiv yog tus yuam sij, thiab cov lus Askiv yog tus nqi rau txhua qhov nkag. Rau txhua lub cim uas xav tau kev hloov pauv kom siv, yooj yim nkag mus ua tus cim Askiv ua tus ntawv. Ntxiv mus, txhawm rau txheeb xyuas phau ntawv txhais lus peb yuav xav ua tus yuam sij sib txawv uas ua rau cov npe tawm ntawm cov yuam sij () ntawm phau ntawv txhais lus. Thaum kawg, peb tuaj yeem siv random.shuffle los sib xyaw cov npe tseem ceeb.

Kauj Ruam 3: Tsim rau thiab Thaum Loops

Tsim rau thiab Thaum Loops
Tsim rau thiab Thaum Loops

Ua ntej tsim lub voj uas mus dhau cov npe ntawm cov yuam sij koj tau ua. Hauv qab ntawd, tsim qhov sib txawv hu ua kev sim thiab muab nws rau 3 (lossis txawm li cas los xij ntau yam koj xav tau tso cai rau ib nqe lus nug). Tom qab ntawd, tsim lub sijhawm True loop, thiab ua rau koj cov neeg siv nkag hauv qab ntawd, muab nws rau qhov sib txawv hu ua tus nqi. Tus nqi yuav tsum suav nrog tus yuam sij peb tab tom rov ua dua ib txoj hlua uas nug tus neeg siv rau cov lus teb ua lus Askiv.

Kauj Ruam 4: Tsim Peb Lub Sijhawm Loop Li Cas

Tsim Peb Thaum Loop Cov Cai
Tsim Peb Thaum Loop Cov Cai

Peb yuav muaj 4 qhov xwm txheej tseem ceeb rau lub sijhawm voj: yog tus neeg siv raug, yog tias lawv xav hla (los ntawm kev nkag mus rau qhov chaw tsis muaj dab tsi), yog tias cov lus nkag tsis yog ib tsab ntawv, lossis yog lawv cov lus teb tsis raug. Yog tias lawv cov tswv yim sib npaug rau cov tsiaj ntawv [qhov tseem ceeb], luam tawm 'Kho', ntxiv 1 rau qhov sib txawv kom raug ces tawg. Yog tias lawv cov tswv yim tsis muaj dab tsi, peb yuav luam tawm 'Hla', ntxiv lawv cov lus teb rau phau ntawv txhais lus tsis raug ces tawg. Thaum kawg, yog tias lawv cov tswv yim tsis yog tus lej thiab tus lej, lossis qhov ntev ntawm cov tswv yim loj dua 1, peb qhia lawv tias lawv cov tswv yim tsis raug.

Kauj Ruam 5: Txheeb Nrog Cov Lus Teb Tsis raug

Kev Cuam Tshuam Nrog Cov Lus Teb Tsis raug
Kev Cuam Tshuam Nrog Cov Lus Teb Tsis raug

Hauv peb cov lus tshaj tawm tom kawg, peb yuav tsum xub kuaj xyuas seb muaj pes tsawg tus neeg siv tau ua. Yog tias tus neeg siv tsuas muaj 1 txoj kev sim sab laug, tom qab ntawd peb ntxiv cov lus teb rau phau ntawv txhais lus tsis raug, luam tawm cov lus teb raug, tom qab ntawd tawg. Rau cov lus hais ntxiv uas tseem tshuav (yog tias lawv tseem muaj kev sim sab laug), rho 1 los ntawm kev sim, qhia rau tus neeg siv kom sim dua, thiab luam tawm tias muaj pes tsawg qhov kev sim ua.

Kauj Ruam 6: Pom Cov Ntsiab Lus

Pom Cov Ntsiab Lus
Pom Cov Ntsiab Lus

Ib feem nyuaj lawm! Tam sim no, peb tsuas yog xav ntxiv ob peb nqe lus luam tawm kom pom peb cov txiaj ntsig. Ua ntej tshaj, luam tawm tias tus neeg siv tau txais qhov raug ntawm qhov ntev ntawm tus niam ntawv. Txhawm rau qhia ntu tom ntej, sau 'Koj tau txais cov hauv qab no tsis raug:'. Tom qab ntawd, siv lub voj rau rov ua dua los ntawm phau ntawv txhais lus tsis raug. Tom qab ntawd, luam tawm txhua tus yuam sij ua raws tus nqi. Nco ntsoov hu koj lub luag haujlwm thaum kawg ntawm cov ntawv los ntawm kev ntaus nws lub npe tsis muaj kev cuam tshuam los ntawm ob kab lus. Thiab nrog qhov ntawd, peb cov ntaub ntawv tiav!

Kauj Ruam 7: Xeem Koj Txoj Haujlwm

Xeem Koj Txoj Haujlwm
Xeem Koj Txoj Haujlwm

Nias f5 kom khiav koj qhov program. Nco ntsoov xyuas txhua yam ntawm koj cov xwm txheej, suav nrog cov lus teb raug, teb tsis raug, hla, thiab nkag tsis raug. Cov duab txuas nrog qhia pom qhov piv txwv piv txwv yuav zoo li cas.

Kauj Ruam 8: Xaus Kev Xav

Yog tias koj tau ua qhov no deb, ua haujlwm zoo! Tam sim no koj tuaj yeem xeem koj tus kheej tsis kawg kom txog thaum koj yog tus kov ntaus ntawv hauv koj hom lus. Nab hab sej muaj peev xwm kawg, yog li tsis txhob ntshai tinker ib puag ncig txhawm rau ntxiv lossis hloov cov yam ntxwv ntawm txoj haujlwm. Ua tsaug rau koj nyeem!

Pom zoo: