Shonascript Learn
Shonascript Learn
Shonascript Learn
Table of contents:
ShonaScript Chii?
Zvii zvinodiwa?
Tanga Pano
STEP 1: Node JS
STEP 2: VS Code
STEP3: Gadzira Folder "shonascript"
Step 4: ShonaScript
Ma Variables
Variable Chii?
Manyorerwo ema variables
Unoona sei kuti variable yako yadzirwa?
Nyora
Nyora Chii?
Mashandisirwo a nyora()
Zvinobvumidzwa muna nyora()
Kupa nyora() zvakawanda
Enzaniso
Enzaniso chii?
Mashandisirwo e enzaniso
Kana, Zvimwe
Kana/Zvimwe chii?
Mashandisirwo a Kana na Zvimwe
Unoshanda kuzvitupa
Ma list
Ma list chii?
Manyorerwo e list
Mashandisirwo e list
Muenzaniso: Vanhu mu kombi
Kuverenga zvinhu zviri mu list
Kuisa zvinhu mu list
Kubvisa zvinhu mu list
Kutora chinhu kubva mu list
Kupinda mu list
Kutsvaga chinhu mu list
Kujamba chinhu mu list
Kubuda mulist
Mashoko
Mashoko chii?
Kutsemura Mashoko
Kutsemura Mavara mumashoko
Kubatanidza mashoko
Maths
Maths ne ShonaScript
Nhamba.chero()
Gadzira Gemhu (Game)
Nguva ne Zuva
Nguva
Zuva
Ma Functions
Ma function chii?
Basa ne ma variable
Basa re Maths
Basa rinoshanda ne nguva
Mirira _ seconds
Dzokorora _ seconds
Kushandisa misaBasa.
Mhinduro
Waakushanda kuzvitupa zvekare
Ma Objects
ShonaScript to JavaScript
ShonaScript to Python
On this page
ShonaScript Chii?
NOT YET REVISED
ShonaScript i programming language inokubatsira kuti udzidzire kunyora code ne shona, kana usati
wambonyora code zvachose.
TSANANGURO
programming language - i language inonzwisiswa ne computer
code - ma words, ma numbers, kana ma special characters akaita se ma brackets aya "{},()"
anoshandiswa mu programming language
Zvii zvinodiwa?
Kuti ugone kutanga kunyora code ne ShonaScript, panodiwa:
Tanga Pano
Teedzera masteps aya anodiwa kuti ugone kushandisa ShonaScript . Kana uchida kubatsirwa,
unokurudzirwa kutaura mugroup re whatsapp
STEP 1: Node JS
DOWNLOAD NODE JS
Unofana kudownloader software inonzi Node JS kana usati wamboidownloader. Node JS inogona
kukura zve 55MB
Unogona kuona video riripazasi apa kana uchikwanisa. Video iri harina kugadzirwa nesu, asi kana
usiri kunzwisisa zvikuitika, bvunza mu group re whatsapp
STEP 2: VS Code
Uchashandisa VS Code kunyora code yako. Usashandise imwe editor kunze kwe VS Code , nekuti VS
Code ndiyo inokwanisa kuona ShonaScript .
DOWNLOAD VS CODE
VS Code inogona kukura zve 171MB
chienda pakanzi Open Folder , wotsvaga folder rako rawagadzira mu desktop rakanzi
shonascript
Onyora mu search box kuti ShonaScript , unofana kuona ShonaScript semu picture iri
pamusoro apa. Wa downloader inonzi syntax highlighter apa.
4. Mu terminal :
9. Mu terminal , nyora kuti node shona.js , wobaya enter . Unofana kusaona ma line e red
mu terminal kana code yako ichishanda.
10. Mu terminal , nyora kuti node index.js , wobaya enter . Unofana kuona mu terminal
imomo makanzi Goodluck Zimbabwe .
Ma Variables
NOT YET REVISED
Variable Chii?
Kuti unzwisise kuti ma variables chii, ndichapa muenzaniso we hembe yaunofarira . Ngatimboti iwewe une
hembe yaunofarira, hembe iyoyo ndeye red . Iwewe ukuda kutuma mumwe munhu asingazive
nezvehembe dzako kunotora hembe yaunofarira kwayakarongedzwa. Ukangoudza munhu uyu, kuti “enda
kunotora hembe yandofarira”, munhu uyu achakubvunza kuti hembe yaunofarira yakaita sei, nekuti
akaenda kunoitsvaga iye asingaizive haamboiwane.
TSANANGURO
Iwewe ndiwe munhu ari kuda kunyora code ne Shonascript kunotsvaga hembe yaunofarira .
Image Here
Image Here
Ukaisa ma words 2 kuti hembe yandinofarira = "ndeye red" , computer ichafunga kuti ukuedza
kunyora two ma variables hembe na yandinofarira panguva imwe chete, saka inokuudza kuti
manyorero awaita hembe yandinofarira haasiriwo . Tarisa mamwe manyorero asinganzwisiswe
ne computer mu box re red pazasi
hembe yandinofarira = "ndeye red" -> ku left kunofana kuenda one word
1hembeYandinofarira = "ndeye red" -> usatange zita re variable ne number kana !@#$%^&*
hembe-yandinofarira = "ndeye red" -> usaise hyphen(-) muzita re variable , asi unogona
kushandisa underscore () kubatanidza ma _words kuita one sezvambotaurwa
Chekutanga, unoona kuti pane ma quotes (""). Zvinhu zvese zviri mu ma quotes zvinoverengwa ne
computer se chinhu chimwe chete, semashoko, uye zvinoverengwa sezvazviri. Ukasaisa ma quotes
ukati hembeYandinofarira = ndeye red , computer ichatarisa kuti chinhu chiri kuright kwe equal
sign (=) ichiedza kuda kuona kuti:
Saka kana computer yaona kuti ku right hakuna zvinhu izvi, ichaona sokuti zvese zviri kuright i
variable . Asi ku right kune 2 mashoko aisira muma quotes, saka ichaona kunge urikuda kunyora 2
ma variables panguva imwe chete yokuudza kuti manyorero awaita haasiriwo . Asi kana
kuright kwacho kuine word rimwe chete, sokuti hembeYandinofarira = red , computer ichaona kuti
waisa variable ku right , yoedza kutsvaga kuti variable inonzi red yambogadzirwa here mu
code yako.
Kana computer ikashaya variable inonzi red yairi kutsvaga, inonyora kuti variable inonzi
red haisi kuzivikanwa .
Nyora
NOT REVISED YET
Nyora Chii?
Nyora i function yaunotuma kuita basa rekunyora zvinhu mu terminal . Unozonzwisisa zvema
function kana waverenga nezvawo kumberi, asi panguva ino chimbongoziva kuti ma function anoita
basa raanenge atumwa.
Mashandisirwo a nyora()
Image here
Image here
TSANANGURO
Line 1
nyora("Hesi")
Apa nyora() apihwa mashoko ekunyora, mashoko acho ndi "Hesi". "Hesi" apa anotariswa ne
computer semashoko nekuti akaiswa mumaquotes "". Kana computer ichinge yatumwa kunyora
mashoko, inongonyora mashoko sezvaari. Saka Ukateedzera ma steps aya wega:
ITA
Hesi
TSANANGURO
Line 2
nyora(2021)
Computer inozviona kuti i nhamba kana iri nhamba chaiyo isina kuiswa muma quotes "" .
Uchazonzwisisa tsananguro yema quotes ukaramba uchiverenga. Panguva ino dzokorora ma steps 3
ambotaurwa mu box re green pamusoro pana Ita, asi nyora kuti nyora(2021) panzvimbo ya
nyora("Hesi") . Unofana kuona mu terminal makanzi:
2021
Line 4 na Line 5
zitaRangu = "Panashe"
nyora(zitaRangu)
Apa tatanga nekugadzira variable . Kana usati waakunzwisisa kuti variable chii, unogona
kuverenga nezvawo kumashure kune topic yema variable . Variable yagadzirwa apa ndi
zitaRangu , ichibva yanzi ndi "Panashe" . Unogona kubvisa pakanzi "Panashe" , oisa zita rako riri
muma quotes. Usasiye maquotes, nekuti hazvishande.
Izvi zvinoreva kuti tikazotuma computer kunotsvaga variable inonzi zitaRangu , inofana kudzoka
na "Panashe" . Saka pa line 5 , takuudza computer kuti nyora(zitaRangu) , ichaona kuti
nyora() uye apihwa zvekunyora, asi zvekunyora zvacho hazvisi kuma quotes, saka haasi mashoko .
Computer ichatarisa kuti kana asiri mashoko, saka i nhamba here? Kwete.
Saka zvaakureva kuti nyora apihwa variable . Variable ichatsvagwa kumashure kuti
wamboigadzira here. Saka apa, hongu, waigadzira zitaRangu = "Panashe" pa line 4 . Ukaita
ma steps 3 aye ari mu box rakanzi Ita pamusoro apa, unofana kuona mu terminal makanzi:
Panashe
Sekutsanangurwa kwaitwa pana line 4 na line 5 , apa nyora() apihwa zvekunyora, asi
zvekunyora zvacho i variable . Computer ichatsvaga variable inonzi zitaRake kumusoro kwe
code yako, yobva yaishaya. Saka ukada kudzokorora ma steps 3 aye ekumashure uku, uchona kuti
pauchanyora mu terminal kuti node shona.js , uchanzi:
zvinhu zvese zvaiswa muma quotes chero zvisingareve chinhu zvinotariswa ne computer se
mashoko saka zvinongonyorwa zvakadaro
2. nhamba
nhamba inonyorwa iri one. Kuti nyora(20 21) hazviite nekuti 20 na 21 atove ma nhamba
akasiyana ari 2. Uchazoona pazasi kuti kana uchida kunyora zvinhu zvakawanda uye zvakasiyana
siyana muma brackets a nyora() unoita sei
3. ma variables
kana usati waakunzwisisa kuti ma varibles chii, enda kumashure kune topic yema varables kuti
ugonzwisisa
Kunyora zvakawanda kwatiri kutaura apa ndiko kutuma nyora() kuti anyore zvakawana panguva imwe
chete. Ngatimboti iwewe ukuda kuti nyora() anyore ma nhamba 2. Manhamba acho ndi 2021 na 2022,
unonyora sei?
Image here
Image here
Line 1
nyora(2021,2022)
Apa, nyora() apihwa zvinhu 2; nhamba 2021 na nhamba 2022. Pakati pema nhamba aya pane ma
comma , zvichireva kuti ukuudza computer kuti 2021 na 2022 ma nhamba akasiyana.
nyora(2021 2022)
Computer ichatadza kunzwisisa kuti 2021 2022 chii, nekuti haisi nhamba , mashoko , kana
variable . Saka ichakuudza kuti paita problem
Line 2 na Line 3
Apa tatanga nekugadzira variable inonzi zitaRangu . Saka pa line 5 , ukupa nyora() zvinhu 2:
Enzaniso
Enzaniso chii?
NOT YET REVISED
MHANDO YEENZANISO
1. Yakafanana na variableYechipiri here?
2. Idiki pane variableYechipiri here?
3. Ihombe kudarika/kupfuura variableYechipiri here?
Mashandisirwo e enzaniso
Mashandisirwo chaiwo e enzaniso uchazomaoona kana waverenga topic ye Kana, Zvimwe . Asi
panguva ino unogona kumboona zvinoitika panenge pachishandiswa enzaniso .
Image here
Chii chikuitika apa? 🤯
TSANANGURO
Line 1 na Line 2
variableYekutanga = 5
variableYechipiri = 6
Line 4 na Line 5
Apa tiri kuda kuona kuti variableYekutanga yakafanana na variableYechipiri here, saka
tashandisa yakafanana na . Ukaenzanisa ma variable aya, unofana kuona kuti akaenzana here
kana kuti kwete.
Tagadzira variable inonzi zvakafananaHere tichibva taita kuti variable iyoyo iite zvinhu
zvichabuda pakuenzanisa ma variableYekutanga na variableYechipiri . Tinoita izvi nekuti
tikuda kuzonyora variable iyoyo tione kuti chii chaitika pataenzanisa.
Chiita izvi wega unone zvinoitika
ITA
1. mu file rakanzi index.shona nyora:
variableYekutanga = 5
variableYechipiri = 6
zvakafananaHere = variableYekutanga akafanana na variableYechipiri
nyora(zvakafananaHere)
false
TSANANGURO
Line 7 na Line 8
Matsanangurirwo aitwa pa line 4 na line 5 akafanana ne matsanangurirwo epa line 7 na line 8. Asi
changochinja ndechekuti tiri kuda kuona kuti variableYekutanga idiki here pana
variableYechipiri . Ukadzokorora masteps 3 arimu box re green rakanzi Ita, unofana kuona mu
terminal makanzi:
true
Line 10 na Line 11
Matsanangurirwo aitwa pa line 4 na line 5 akafanana ne matsanangurirwo epa line 7 na line 8. Asi
changochinja ndechekuti tiri kuda kuona kuti variableYekutanga ihombe here pana
variableYechipiri . Ukadzokorora masteps 3 arimu box re green rakanzi Ita, unofana kuona mu
terminal makanazi:
false
False zvireva kuti kunyepa. Zvechokwadi variableYekutanga (5), haasi muhombe pane
variableYechipiri (6)
Kana, Zvimwe
NOT REVISED YET
Kana/Zvimwe chii?
Pane dzimwe nguva dzekuti iwewe unogona kuda kuudza computer kuti itarise uye ishandise chidimbu
che code mushure mekunge kana chimwe chinhu chiri chokwadi, ndopanoshanda kana . Kana chinhu
ichocho chisiri chokwadi , unenge uchiudza kuudza computer kuti ishandise imwe code isiri muma
brackets a kana . Code iyoyo inozoshandiswa inoiswa muma brackets a zvimwe
ZVATICHASHANDISA NA KANA/ZVIMWE
1. ma variable
2. enzaniso
3. nyora()
Kana usina kunzwisisa kuti ma variables ne enzaniso chii, unokurudzirwa kuverenga ma topic iwayo
zvekare, uyezve unogona kubvunza mu group re whatsapp kuti ubatsirike
Iwewe semunhu aakugona kushandisa ShonaScript , ukuda kuita kuti munhu auya kuzotora chitupa
audzwe zvekuita ne computer . Saka uchanyora code inoita izvi uchiteedzera masteps ari pazasi apa.
RONGA
Step 1 : Kugadzira ma variables
Saka zvawaona kuti tichada kuzoshandisa enzaniso , zvaakureva kuti tikufana kugadzira ma
variables 2 aya:
1. makoreAnobvumidzwa
Ndiyo variable yemakore anobvumidzwa kuti munhu atore chitupa (16 years)
2. makoreEMunhu
Ndiyo variable yemakore e munhu auya kuzotora chitupa. Pakutanga apa ngatimboti makore
emunhu auya kuzotora chitupa nhasi ane makore 15
ITA
1. Pa line 1 mu index.shona , nyora kuti
makoreAnobvumidzwa = 16
makoreEMunhu = 15
se izvi:
Image here
USANYORE SE IZVI
Usagadzire variable yako uchiti: makoreAnobvumidzwa = 16 years
Izvi hazviite nekuti ukadzokora kunoverenga nezve ma variables , uchaona kuti computer
ichatarisa ku right side kwe equal sign (=) yobva yaona kuina 16 years . Zvichaitika ndeizvi:
Iwewe wanga ukuda kuenzanisa makore, saka makore i nhamba , zvichireva kuti paunogadzira ma
variable ako, unofana kuisa nhamba ku right side kwe equal sign.
ITA
} zvimwe {
se izvi:
Image here
TSANANGURO
Kana enzaniso iyo iri chokwadi , tikuda kuti computer ishandise code iri muma curly brackets {}
ekutanga. Asi kana enzaniso isiri chokwadi tikuda kuti computer ishandise code iri muma curly
bracket echipiri anoteera zvimwe .
Kana wapedza kunyora code yako, chiona kuti mu terminal munonyorwa kuti chii. Zvekare kuti unoita izvi
kana uchida kuti code yako isande
ITA
1. mu index.shona , nyora code iri mu picture
2. mu terminal nyora kuti node shona.js , wobaya enter
3. mu terminal zvekare, nyora kuti node index.js , wobaya enter
Zvechokwadiwo makoreEMunhu anga ari 15 zvichireva kuti haasi aakukwanisa kutora chitupa.
ITA
makoreEMunhu = 18
Ma list
NOT REVISED YET
Ma list chii?
Kana iwewe uchida kuenda kunotenga zvinhu zvakawanda, unogona kunyora zvinhu zvaukuda kunotenga
pa pepa kana mu phone . Kana uchinge waita izvi, tinoti wanyora list rezvaukuda kunotenga.
Manyorerwo e list
Computer inoziva kuti wanyora list kana ukanyora ma square brackets se izvi:
TSANANGURO
Apa ndagadzira list re mazuva 3 kubva pana Muvhuro kusvika pana Chitatu. Mu list
randagadzira iri, mune zvinhu 3. zvinhu izvi zvandaisa mu list aya mashoko ane ma quotes
akapatsanurwa ne ma comma, .
sokuti: ["Muvhuro","Chipiri","Chitatu"]
2. Ma nhamba
3. Ma variables
sokuti:
muvhuro = "Muvhuro"
chipiri = "Chipiri"
chitatu = "Chitatu"
Mashandisirwo e list
Kazhinji munhu anogadzira list achida kuzorishandisa. Anogona kuda kudzima zvinhu mu list imomo,
kana kuwedzera zvimwe zvinhu. Kuti ugone kuzoshandisa list raunenge wagadzira, unofana kuripa zita.
Unopa list zita kunge uri kugadzira variable . Ngatimboti list randagadzira kumashure
["Muvhuro", "Chipiri", "Chitatu"] waakuda kuripa zita rekuti mazuva , unoita se izvi
ZITA RE LIST
Zita re list rinonyorwa semagadzirirwo evariable. Manyorero anoita ndeaya:
sokuti listRangu
usati list Rangu , nekuti aya mashoko maviri
ITA
1. mu index.shona pa line 1 , nyora kuti:
nyora(vanhuMukombi)
Izvi zvinoitika nekuti wagadzira list re vanhuMukombi zvakanaka, wobva wazoudza computer kuti inyore
list iri ichishandisa nyora(vanhuMukombi)
vanhuMukombi.vangani()
Image here
Image here
ITA
Ukaita izvi zvakanaka, unofana kuona mu terminal makanyorwa nhamba yezvinhu zviri mu
vanhuMukombi kuti:
TSANANGURO
Pa Line 2 :
tashandisa .vangani() pane vanhuMukombi kuti tiwane nhamba yevanhu vari mu list rako
tobva tagadzira variable inonzi x .
Tagadzira variable iyi nekuti tikuda kuzoinyora mu terminal tichishandisa nyora()
vanhuMukombi.isa("Ruvarashe")
nyora(vanhuMukombi)
Zvichireva kuti taisa zita ra "Ruvarashe" mu list redu zvakanaka, saka mukombi maane vanhu 6
Image here
Image here
Ukateedzera zviri mu picture iyi, unofana kuona mu terminal makanzi
TSANANGURO
Izvi zvinoitika nekuti nyora() atumwa ka 2 kunyora mu terminal :
1. Atumwa kunyora usati waisa "Ruvarashe" na "Tatenda" mu list , saka pekutanga nyora
anongonyora list riine vanhu 5 chete
2. Pazotumwa nyora pa line 5 , "Ruvarashe" na "Tatenda" vanga vaiswa mu list , saka
nyora anobva anyora vanhu vese vari 7 kusanganisira "Tatenda" na "Ruvarashe"
vanhuMukombi.bvisa("Kudzai")
Image here
Image here
TSANANGURO
1. nyora(vanhuMukombi) wepa line 2 ndiye anyora kuti:
Iwewe zvawaane vanhu 6 mukombi, uchati vanhu 6 ava vakagara pa masiti 6. Tarisa list rako iri:
"Panashe" aripasiti 1
"Tanaka" aripasiti 2
"Kupa" aripasiti 3
"Vmbai" aripasiti 4
"Ruvarashe" aripasiti 5
"Tatenda" aripasiti 6
"Tatenda" aripasiti vanhuMukombi[5] Aya ndiwo matarisiro anoita computer zvinhu zviri
mu list . Unogona kutora chinhu mu list ogadzira variable kuti uone kuti chii chinoitika
ITA
1. mu index.shona , pazasi pe code yawambonyora, nyora kuti
munhu = vanhuMukombi[1]
nyora(munhu)
Ukaita izvi zvakanaka, uchaona kuti nyora() wekupedzisira anonyora chinhu chiri pa nhamba 2 mu list
rako, kwete pekutanga, nekuti chinhu chekutanga chiri pa nhamba 0 kwete 1
Kupinda mu list
Iwewe sa hwindi ane hunhu, ukuda kumhoresa munhu mumwe nemumwe arimukombi yako nezita rake
nekuti unoziva mazita avo. Unoita sei? Tichaedza kuita izvi nenzira 2, asi wega uchazviona kuti ndezvipi
zvirinani.
nyora("Hesi Panashe")
enda pa line 3 onyora kuti:
nyora("Hesi Tanaka")
enda pane line riri kutevera uchidzokorora kumhoresa munhu arimo sezvaitwa pa line 2 na line
3 , upedzisire pane line 6 . Tarisa picture iri pazasi kuti uone maitirwo azvo
nyora("Vimbai")
Image here
Image here
Kana mu list mako muine vanhu 1000, zvinoreva kuti kana uchida kuvamhoresa vese nenzira iyi, uchanyora
ma line 1000 mu index.shona uchimhoresa munhu mumwe ne mumwe.
Tiri kuda kutuma computer kupinda mulist. Unopinda sei? Chimbotarisa manyorero ataita pazasi:
Image here
Image here
Ko pana Line 3?
Line 3 arimuma curly brackets saka zvinoreva kuti computer ichasandisa code iyi kana ichinge
yapinda mu list rako re vanhuMukombi .
1. "Hesi " arimuma quotes, zvichireva kuti mashoko saka computer inonzwisisa kuti "Hesi "
achanyorwa mu terminal sezvaari
2. munhu haasi mu ma quotes, zvichireva kuti haasi mashoko , uye haisi nhamba , saka computer
inonzwisisa kuti munhu i variable
computer ichatsvaga kuti variable inonzi munhu inopinda mu list yambogadzirwa here?
Hongu, yagadzirwa pa line 3
Kana computer yapinda mu list rako, inotanga pane chinhu chekutanga mulist rako. Saka apa
inotanga pana "Panashe" . Kana computer iri pana "Panashe" , variable inonzi munhu ichachinja
kuita "Panashe" .
munhu = "Panashe"
Apa munhu ndi "Panashe" , saka mu terminal muchanyorawa kuti Hesi Panashe .
Kana computer yapedza kushandisa code iri muma curly brackets {} pana "Panashe" , ichaenda
pane chinhu chiri kutevera mu list rako yoita sezvayaita pana "Panashe" . Saka variable munhu
ichachinja kuita munhu = "Tanaka" yonyora nyora("Hesi ",munhu) , zvichingodaro kusvika
yapedza nevanhu vese vari mulist rako
Image here
Image here
arimoHere = vanhuMukombi.muna(munhuAkutsvagwa)
arimoHere = munhuAkutsvagwa irimu vanhuMukombi
Pa line 3 , tiri kuudza computer kuti tarisa mu vanhuMukombi kuti muna variable inonzi
munhuAkutsvagwa here, munhuAkutsvagwa wacho ndi "Kudzai" agadzirwa pa line 2
Pa line 4 , tangoita zvakafanana nepa line 3 , asi tikuudza computer kuti tarisa variable
inonzi munhuAkutsvagwa kuti irimu vanhuMukombi here. Iwewe unoshandisa line 3 kana line 4,
zvichienderana nezvawanzwisisa
ITA
Nyora code iyoyi mu index.shona , wochiita izvi:
true
true zvinoreva kuti chokwadi , zvechokwadiwo "Kudzai" arimo mu vanhuMukombi .
DANGER
Chimboedza kuchinja pana munhuAkutsvagwa = "Kudzai" , woisa munhuAkutsvagwa =
"Kudzi" . Wodzokora zvawaita pamusoro apa. Unofana kuona mu terminal makanzi:
false
Image here
Image here
munhuWandakavenga = "Kupa"
Apa tagadzira variable inonzi munhuWandakavenga , tobva tati variable iyoyo ndi "Kupa" .
Line 3
Line 4
Apa tatove mu list kare, saka tine variable inonzi munhu , ichange ichichinja patinenge
tichifamba kubva pane chinhu chekutanga mu list kusvika pane chekupedzisira. Tiri kuudza
computer kuti kana variable munhu yachinja kuita munhu = "Kupa" , inobva yafanana na
munhuWandakavenga . Kana izvi zvichinge zvaitika, computer inofana ku jamba munhu iyeye.
Ku jamba apa zvinoreva kuti computer icharega kushandisa code yese ichatevera kumberi kwa
jamba mumabrackets a kana , yobva yaenda pane munhu arikutevera mu list
ITA
Nyora code iyoyi mu index.shona , wochiita izvi:
Hesi Panashe
Hesi Tanaka
Hesi Kudzai
Hesi Vimbai
Image here
Image here
Apa tashandisa kana na zvimwe , kana usina kunzwisisa kuti kana na zvimwe vanoshanda sei,
unokurudzirwa kuverenga topic ya Kana, Zimwe. Unogona kubvunza pa whatsapp mugroup kuti
ubatsirwe.
Tikuudza computer kuti ichinge yapinda mu list , kana variable inonzi munhu yakafanana na
munhuWandakavenga , hapana zvaunoita. Hatina kuisa code muma curly brackets epana kana
zvichireva kuti computer hapana zvainoita kana tikasvika pane munhuWandakavenga . Asi kana
varibale inonzi munhu isina kufanana ne variable inonzi munhuWandakavenga , computer
ichashandisa code iri muma brackets {} a zvimwe .
ITA
Nyora code iyoyi mu index.shona , wochiita izvi:
1. mu terminal , nyora kuti: node shona.js wobaya enter
Hesi Panashe
Hesi Tanaka
Hesi Kudzai
Hesi Vimbai
Kubuda mulist
Kana computer ichinge yapinda mu list , inotangira pane chinhu chekutanga kusvika pane chinhu
chekupedzisira chiri mu list imomo.
Unoshandisa buda kubuda mu list . Ngatomboti iwewe ukuda kumhoresa vanhu 3 chete varimukombi
yako iya, obva wanyarara hako, nekuti haudi zvekunyanya kutaura taura.
Image here
Image here
Pa line 4
Pa line 5 na line 6
Tikuda kuwedzera nhambaYeVanhu na 1 kana tave kufamba kubva pane chinhu chimwe ne
chimwe mu list .
Patinopinda mu list , tinotanga tiri pane munhu wekutanga, saka apa tikuudza computer kuti
nhambaYeVanhu ngaiwedzere na 1 kubva pana 0 , saka yave 1
Pa line 6 , tikuudza computer kuti nyora() zvinhu 3:
i. "Hesi " - aya mashoko anonyora wezvaari
ii. munhu - i variable yekupinda mu list , saka panonyorwa zita remunhu
iii. nhambaYeVanhu - i variable ichange ichiwedzera na 1 sekufamba kwatinenge tichiita
kubva pane munhu wekutanga mu list tichienda mberi
ITA
Hesi Panashe 1
Hesi Tanaka 2
Hesi Kudzai 3
ma nhamba aya ekumberi kwemazita ndiwo nhambaYeVanhu iri kuwedzera kana tapinda mu list .
nhamba iyi paichaita 3 , computer ichabva yabuda mu list , ndosaka mamwe mazita asina kuzonyora
mu terminal , nekuti tanga tatobuda kare mu list
Mashoko
ZVICHIRI KUNYORWA
Mashoko chii?
Mashoko zvinhu zvese zvakaiswa mu ma quotes "" sokuti:
"2021" aiswa muma quotes saka mashoko haisi nhamba . 2021 inhamba, "2021" mashoko . Izvi
zvakakosha kuziva pauchazoverenga nezve topic ye Maths kumberi uku.
Kutsemura Mashoko
Kana uine mutsara wakanzi
ITA
1. mu file rakanzi index.shona , nyora kuti:
ITA
1. mu file rakanzi index.shona , nyora kuti:
zita = "Panashe"
listReMavara = zita.tsemuraMavara()
nyora(listReMavara)
["P","a","n","a","s","h","e"]
Kubatanidza mashoko
HAZVISATI ZVANYORWA
Edit this page
On this page
Maths
NOT YET REVISED
Maths ne ShonaScript
Unogona kuita maths ne ShonaScript dzemhando yakasiyana siyana. Ngatimbotora addition
(kusanganisa) semuenzaniso:
Image here
Image here
ITA
ITA
Chibvisa + aripakati pa 45 na 5, oisa - , oita masteps emuterminal aripamusoro apo uone zvinoitika.
+ - addition (kusanganisa)
- - subtraction (kubvisa)
* - multiplication
/ - division
Nhamba.chero()
ShonaScript ine function inoita basa rekupa chero nhamba iri pakati pa 0 na 9.
Image here
Image here
ITA
Nyora code iyoyi mu index.shona , wochiita izvi:
Ukaramba uchingodzokorora izvi, unoona kuti mu terminal muri kunyorwa ma nhamba akasiyana siyana
asi ma nhamba aripakati pa 0 na 9.
Unoita izvi:
x = nhamba.chero(6)
nyora(x)
Chachinja apa ndechekuti muma brackets a nhamba.chero() maiswa nhamba 6. Ukaisa nhamba muma
brackets a nhamba.chero() unenge uchiudza computer kuti ikupe chero nhamba iri pasi pe nhamba
yaiswa muma brackets. Sezvo taisa 6 muma brackets apa, zvaakureva kuti computer inokupa chero
nhamba iri pakati pa 0 na 5 kwete 0 na 6. Ukaisa nhamba muma brackets sezvataita pekutanga,
computer inokupa chero nhamba iri pakati pa 0 na 9
MUTEMO WE GEMHU
1. Pane zvinhu 3 zvaunokwanisa kusarudza:
dombo
pepa
chigero
1. Tichagadzira variable yesarudzo yedu, yatichati sarudzoYangu ndobva ndati ndi "dombo"
sarudzoYangu = "dombo"
Uchatanga wagadzira list re sarudzo dzese riine "dombo", "pepa", ne "chigero" seizvi:
sarudzoDzese = ["dombo", "pepa", "chigero"]
nhambaYaSarudzwa = nhamba.chero(3)
Apa panogona kubuda 0,1,kana kuti 2. Hatizive zvichabuda ipapo kusvikira taita kuti code
yedu ishande
Computer yaakukwanisa kushandisa variable ye nhambaYaSarudzwa iya pakusarudza chero
pakati pa "dombo", "pepa", ne "Chigero" ichiti sarudzoDzese[nhambaYaSarudzwa] seizvi:
sarudzoYeComputer = sarudzoDzese[nhambaYaSarudzwa]
Tichazoshandisa kana , ne enzaniso kutarisa kuti adyiwa pa gemhu ndiani. Tarisa pazasi uone
code yacho yese:
Image here
Image here
ITA
Nyora code iyoyi mu index.shona , wochiita izvi:
Kana uchinge usiri kunzwisisa kuti code iyi ikushanda sei, unokurudzirwa kubvunza mu whatsapp group
kuti ubatsirike
Nguva ne Zuva
NOT YET REVISED
Nguva
Kana uchida kuona kuti inguvai uchishandisa ShonaScript, unogadzira variable yenguva seizvi:
nguva = Nguva
nyora(nguva)
ITA
Nyora code iyoyi mu index.shona , wochiita izvi:
Zuva
Kana uchida kuona kuti inguvai uchishandisa ShonaScript, unogadzira variable yenguva seizvi:
zuvaRanhasi = Zuva
nyora(zuvaRanhasi)
ITA
Nyora code iyoyi mu index.shona , wochiita izvi:
Ukaita izvi unofana kuona mu terminal zuva ranhasi racho sokuti 11/21/2021 . Zuva iri rinogona
kunyorwa zvakasiyana neizvi zvichienderana ne computer yaukushandisa
Kana wave kuziva zvema functions , uchazogadzira function inoita kuti unyore nguva mu terminal
ichiverenga ma seconds
Ma Functions
Ma function chii?
Ma functions i code yaunogadzira kana uchida kuzoituma kuti basa kumberi. Nemamwe mashoko, tiri kuti
function i basa . Ngatimboti iwewe ukuda kugadzira basa rino mhoresa munhu. Rinogadzirwa se izvi:
Image here
TSANANGURO
Pa line 5 :
tangaBasa.mhoresaMunhu()
Apa tiri kutuma computer kuita basa ratagadzira rinonzi mhoresaMunhu() .Ma brackets () haasiiwe.
ITA
Hesi
ITA
Izvi zvinoitika nekuti wagadzira basa rekumhoresa munhu, asi hauna kuzoudza computer kuti itanga
basa racho, saka basa hariitwe kana risina kutangwa na tangaBasa.mhoresaMunhu()
Basa ne ma variable
Unogona kugadzira basa rinotora variable inozoshandiswa ne basa racho kana razotanga. Ngatomboti
iwewe ukuda kugadzira basa rinomhoresa munhu asi ukuda kuzopa basa zita remunhu wekumhoresa.
Unoita seizvi:
Image here
Chii chikuitika apa?
TSANANGURO
Apa ukugadzira basa rinonzi mhoresaMunhu , asi ukuudza computer kuti kana basa iri rave
kutangwa, rinofana kupihwa variable inonzi zita ichazoshandiswa na nyora("Hesi ", zita) .
ITA
Nyora code iyoyi mu index.shona , wochiita izvi:
Hesi Panashe
DANGER
Ukada kuenda kutanga basa usina kuisa variable, computer ichakuudza kuti
Image here
TSANANGURO
Kubva pa line 1 kuzvika pa line 4
Apa tiri kugadzira basa rinonzi sanganisa , basa iri rinofana kuzopihwa ma variable anonzi
nhambaYekutanga na nhambaYechipiri anofana kunge ari ma nhamba nekuti haukwanise
kusanganise zvisiri ma nhamba
ITA
Nyora code iyoyi mu index.shona , wochiita izvi:
43
Unogona kuchinja ma nhamba oona kuti chii chinotika, kana kuchinja + oisa - , kana * , kana /
Image here
TSANANGURO
Tangodzokorora kugadzira basa rinonzi mhoresaMunhu sezvataita pakutanga, asi patagadzira basa
iri, taudza computer kuti mirira 3 seconds kuitira kuti kana basa iri razotangwa, rinomirira ma
seconds enguva 3 robva razotanga.
ITA
Nyora code iyoyi mu index.shona , wochiita izvi:
Hesi
Dzokorora _ seconds
Unogona kugadzira basa rinodzokorora rega kuitika kana papera ma seconds enguva aunenge wataura
iwewe sokuti:
Image here
TSANANGURO
Zvekare tagadzira basa reku mhoresaMunhu , asi apa tikuda kuti basa iri rirambe richidzokororwa
kana papfuura 1 second ye nguva.
ITA
Nyora code iyoyi mu index.shona , wochiita izvi:
Hesi
Hesi
Hesi
Hesi
Mu terminal imomo munoramba muchinyorwa kuti Hesi kusvika computer yako yadzima
1. mu terminal , baya control na c panguva imwechete. Izvi zvinofana kuita kuti mu terminal
mumire kunyorwa kuti Hesi
RONGA
i. nyora()
ii. Nguva
iii. dzokorora 1 second
Kana wapedza tarisa code yacho pasi kana yako yaramba kushandisa
Image here
Kushandisa misaBasa.
Unogona kushandisa misaBasa.mhoresaMunhu() kuita kuti basa rimire. Ngatimboti tikuda kumhoresa
munhu la 3 , tobva tamisa basa . Tinoita sei?
RONGA
Tichashandisa zvinhu izvi:
1. basa dzokorora
2. nyora
3. kana
4. enzaniso
5. misaBasa
Answer
Image here
TSANANGURO
Tinotarisira kuti waakunzwisisa zvakawanda zviri mucode umu, saka tichangotsanangur zviri kuitika
kubva pa line 9 kusvika pa line 11
Mhinduro
NOT YET REVISED
Unogona kuda kunyora code inoita kuti munhu apindure mu terminal , sokuti unogona kuda kuti munhu
anyore zita rake mu terminal , iwewe wozotora zita iroro oita zvaunoda naro zvakaita seku mhoresa
munhu iyeye. Tarisa pazasi apa, uone kuti izvi zvinotwa sei:
1. teerera mhinduro _
2. tora mhinduro _ {
Image Here
Tiri kuudza computer kuti iteerere zvichanyorwa mu terminal . Kana yateerera zvichanyorwa,
ichabva yagadzira variable inonzi zita . zita apa ndizvo zvese zvichanyorwa mu terminal .
Kubva pa line 3 kuzvika pa line 5 Apa taakuudza computer kuti tora mhinduro yanyorwa mu
terminal ine variable rekuti zita , obva wa nyora kuti "Hesi ", zita
ITA
mhinduro: zita:
Izvi zvinoreva kuti computer yakamirira iwewe kuti unyore zita rako kana chero rimwe zita
raukuda kunyora, mobva wabaya enter . Ukaita izvi, uchaona mu terminal makanzi:
Ukaita izvi, ukanyora muterminal zita racho, unofana kuona mu terminal makanzi
Image Here
Unoita sei kana uchida kushandisa mhinduro kuwana makore
emunhu
Apa taakuda kunyora code iyi zvekare, asi ikozvino pane kuti ugadzire variable yekuti makoreEmunhu
sezvawakaita pa enzaniso , uchagadzira variable iyoyo uchishandisa teerera mhinduro seizvi:
computer ichamirira kuti makore emunhu anyorwe mu terminal , iwewe wobva watora mhinduro iyoyo
ochishandisa code iri kubva pa line 4 kusvika pa line 8 mu picture iri pamusoro apo. Kana wapedza,
code yako inofana kuita seizvi:
Image Here
ITA
mhinduro: makoreEMunhu:
Izvi zvinoreva kuti computer yakamirira iwewe kuti unyore makoreEmunhu . Saka nyora kuti nhamba
yemakore acho, wobva wabaya enter .
Ukanyora nhamba iri pasi pa 16 sokuti 12, mu terminal munofana kunyora kuti:
Asi ukanyorawo nhamba iri pamusoro pa 16 sokuti 21, mu terminal munofana kunyorwa kuti: