Skip to main content

Maths

Not yet Revised

Maths ne ShonaScript#

Unogona 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

  1. nyora code iyoyi
  2. baya bhatani re round riri pazasi pe screen

Kana kuti

Mu VS Code

Nyora code iyoyi mu index.shona, wochiita izvi:

  1. mu terminal, nyora kuti: node shona.js wobaya enter

  2. mu terminal, nyora kuti: node index.js wobaya enter

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

  1. nyora code iyoyi
  2. baya bhatani re round riri pazasi pe screen

Kana kuti

Mu VS Code

Nyora code iyoyi mu index.shona, wochiita izvi:

  1. mu terminal, nyora kuti: node shona.js wobaya enter

  2. mu terminal, nyora kuti: node index.js wobaya enter

Usachinje chinhu mu index.shona, asi dzokorora izvi uchitarisa mu terminal zvikuitika:

  1. mu terminal, nyora kuti: node shona.js wobaya enter

  2. mu terminal, nyora kuti: node index.js wobaya enter

Ukaramba uchingodzokorora izvi, unoona kuti mu terminal muri kunyorwa ma nhamba akasiyana siyana asi ma nhamba aripakati pa 0 na 9.

Ko kana uchida kuti computer ikupe nhamba iri pakati pa 0 na 5

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
  1. Pane zvinhu 3 zvaunokwanisa kusarudza:
  • dombo
  • pepa
  • chigero
  1. Iwewe uchasarudza pakati pe: dombo, pepa, chigero.
  2. Computer ichasarudza pakati pezvinhu 3 izvozvo asi computer ichashandisa nhamba.chero() kuita izvi
  3. 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
Gemhu iyi tichaigadzira sei?
Ngatironge magaziriro atichaita gemhu
  1. Tichagadzira variable yesarudzo yedu, yatichati sarudzoYangu ndobva ndati ndi "dombo"
sarudzoYangu = "dombo"
  1. Tichagadzira sarudzo ye computer, computer ichasarudza pakati pa "dombo", "pepa", ne "chigero" ichishandisa nhamba.chero().
  • Uchatanga wagadzira list re sarudzo dzese riine "dombo", "pepa", ne "chigero" seizvi:
sarudzoDzese = ["dombo", "pepa", "chigero"]
  • Taakuda kuti computer itore chero chinhu chiri mu sarudzoDzese tichishandisa nhamba.chero(). Ukaisa nhamba muma brackets a nhamba.chero().
  • Kana uchida kutora chinhu chiri pekutanga mu sarudzoDzese, unoshandisa sarudzoDzese[0], izvi zvinoreva kuti pinda mu list rinonzi sarudzoDzese utore chinhu chiri pana 0. chinhu chekutanga mu list chinonzi chiri pana 0. Izvi zvinoreva kuti chinhu chechipirr mu list chiri pana 1
  • Saka zvatiri kutaura apa ndezvekuti:
    • "dombo" ari pana sarudzoDzese[0]
    • "pepa" ari pana sarudzoDzese[1]
    • "chigero" ari pana sarudzoDzese[2]
  • Isusu tikuda kuti computer isarudze chero pakati pe nhamba 0 na 2
    • Kuti tiwane nhamba iri pakati pa 0 na 2 tichishandisa nhamba.chero() tinoti nhamba.chero(3) togadzira variable yenhamba yasarudzwa ne computer iyoyo seizvi:
      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:
Zvekuita

Mu Application ye ShonaScript

  1. nyora code iyoyi
  2. baya bhatani re round riri pazasi pe screen

Kana kuti

Mu VS Code

Nyora code iyoyi mu index.shona, wochiita izvi:

  1. mu terminal, nyora kuti: node shona.js wobaya enter

  2. mu terminal, nyora kuti: node index.js wobaya enter

Kana uchinge usiri kunzwisisa kuti code iyi ikushanda sei, unokurudzirwa kubvunza mu whatsapp group kuti ubatsirike