Maths
Not yet Revised
#
Maths ne ShonaScriptUnogona kuita maths
neShonaScript
dzemhando yakasiyana siyana. Ngatimbotora addition (kusanganisa) semuenzaniso:
Chii chikuitika apa?🤯
Tsananguro
Apa, tikuda kusanganisa nhamba
45 na nhamba
5. Computer kana yasanganisa ma nhamba
aya, ichawana mhinduro yacho, asi iwewe kuti ugone kuona mhinduro yawanikwa ne computer
iyoyo, uchashandisa nyora()
.
Saka tagdzira variable
inonzi x
tobva tati ndiyo ichachengeta mhinduro ichawanikwa ne computer
pakusanganisa 45 na 5.
Ita
Mu Application ye ShonaScript
- nyora
code
iyoyi - baya bhatani re round riri pazasi pe screen
Kana kuti
Mu VS Code
Nyora code
iyoyi mu index.shona
, wochiita izvi:
mu
terminal
, nyora kuti:node shona.js
wobayaenter
mu
terminal
, nyora kuti:node index.js
wobayaenter
ukaita izvi zvakanaka, unofana kuona mu terminal
makanzi 50
Ita
Chibvisa +
aripakati pa 45 na 5, oisa -
, oita masteps emuterminal aripamusoro apo uone zvinoitika.
Dzokorora izvi uchashanisa *
na /
Zvinoreva masymbols eMaths aya:
+
- addition (kusanganisa)
-
- subtraction (kubvisa)
*
- multiplication
/
- division
Nhamba.chero()
#
ShonaScript
ine function inoita basa
rekupa chero nhamba
iri pakati pa 0 na 9.
Ita
Mu Application ye ShonaScript
- nyora
code
iyoyi - baya bhatani re round riri pazasi pe screen
Kana kuti
Mu VS Code
Nyora code
iyoyi mu index.shona
, wochiita izvi:
mu
terminal
, nyora kuti:node shona.js
wobayaenter
mu
terminal
, nyora kuti:node index.js
wobayaenter
Usachinje chinhu mu index.shona
, asi dzokorora izvi uchitarisa mu terminal
zvikuitika:
mu
terminal
, nyora kuti:node shona.js
wobayaenter
mu
terminal
, nyora kuti:node index.js
wobayaenter
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
Nhamba iri muma brackets a nhamba.chero()
Ukaisa 3 muma brackets, computer
inokupa chero nhamba iri pakati pa 0 na 2
Ukaisa 6 muma brackets, computer
inokupa chero nhamba iri pakati pa 0 na 5
Ukaisa 9 muma brackets, computer
inokupa chero nhamba iri pakati pa 0 na 8
#
Gadzira Gemhu (Game)Taakuda kumbogadzira game inonzi rock, paper, scissors. Apa tichaiti dombo, pepa, chigero
Mutemo we gemhu
- Pane zvinhu 3 zvaunokwanisa kusarudza:
- dombo
- pepa
- chigero
- Iwewe uchasarudza pakati pe: dombo, pepa, chigero.
- Computer ichasarudza pakati pezvinhu 3 izvozvo asi
computer
ichashandisanhamba.chero()
kuita izvi - Pakasarudzwa:
- dombo ne pepa, asarudza dombo adyiwa nekuti pepa rinovhara dombo
- dombo ne chigero, asarudza chigero adyiwa nekuti dombo rinotswanya chigero
- pepa ne chigero, asarudza pepa adyiwa nekuti chigero chinocheka pepa
Ngatironge magaziriro atichaita gemhu
- Tichagadzira
variable
yesarudzo yedu, yatichatisarudzoYangu
ndobva ndati ndi "dombo"
sarudzoYangu = "dombo"
- Tichagadzira sarudzo ye
computer
,computer
ichasarudza pakati pa "dombo", "pepa", ne "chigero" ichishandisanhamba.chero()
.
- Uchatanga wagadzira
list
resarudzo dzese
riine "dombo", "pepa", ne "chigero" seizvi:
sarudzoDzese = ["dombo", "pepa", "chigero"]
- Taakuda kuti
computer
itore chero chinhu chiri musarudzoDzese
tichishandisanhamba.chero()
. Ukaisanhamba
muma brackets anhamba.chero()
. - Kana uchida kutora chinhu chiri pekutanga mu
sarudzoDzese
, unoshandisasarudzoDzese[0]
, izvi zvinoreva kuti pinda mulist
rinonzisarudzoDzese
utore chinhu chiri pana 0. chinhu chekutanga mulist
chinonzi chiri pana 0. Izvi zvinoreva kuti chinhu chechipirr mulist
chiri pana 1 - Saka zvatiri kutaura apa ndezvekuti:
"dombo"
ari panasarudzoDzese[0]
"pepa"
ari panasarudzoDzese[1]
"chigero"
ari panasarudzoDzese[2]
- Isusu tikuda kuti
computer
isarudze chero pakati penhamba
0 na 2- Kuti tiwane
nhamba
iri pakati pa 0 na 2 tichishandisanhamba.chero()
tinotinhamba.chero(3)
togadziravariable
yenhamba yasarudzwa necomputer
iyoyo seizvi:Apa panogona kubuda 0,1,kana kuti 2. Hatizive zvichabuda ipapo kusvikira taita kutinhambaYaSarudzwa = nhamba.chero(3)
code
yedu ishande
- Kuti tiwane
Computer
yaakukwanisa kushandisavariable
yenhambaYaSarudzwa
iya pakusarudza chero pakati pa "dombo", "pepa", ne "Chigero" ichitisarudzoDzese[nhambaYaSarudzwa]
seizvi:
sarudzoYeComputer = sarudzoDzese[nhambaYaSarudzwa]
- Tichazoshandisa
kana
, neenzaniso
kutarisa kuti adyiwa pa gemhu ndiani. Tarisa pazasi uone code yacho yese:
Zvekuita
Mu Application ye ShonaScript
- nyora
code
iyoyi - baya bhatani re round riri pazasi pe screen
Kana kuti
Mu VS Code
Nyora code
iyoyi mu index.shona
, wochiita izvi:
mu
terminal
, nyora kuti:node shona.js
wobayaenter
mu
terminal
, nyora kuti:node index.js
wobayaenter
Kana uchinge usiri kunzwisisa kuti code
iyi ikushanda sei, unokurudzirwa kubvunza mu whatsapp group kuti ubatsirike