Skip to main theme

Mipiro

Kuratidza zvinyorwa neelebheri Calculator

Python kodhi iri nyore Calculator

Ichi chirongwa chePython chiri nyore chinobvunza mushandisi kusarudza basa raunoda. Sarudzo dzesarudzo 1, 2, 3 ne4 dzinoshanda. Vaviri kana ... elif ... zvimwe nhamba dzakasarudzwa uye bazi rinoshandiswa kuita imwe chikamu chechirongwa. Mushandisi-akatsanangurwa wedzera (), bvisa (), wedzera (), uye ugovanise () mabasa anoita mabasa akakodzera.
# Iri basa rinowedzera maviri manhamba def anowedzera (x, y): dzoka x + y # Ichi chiitwa chinodzikisa manhamba maviri def subtract (x, y): dzoka x - y # Iri basa rinowedzera nhamba mbiri kuwanda () x, y): dzoka x * y # Ichi chiitiko chinopatsanura maviri manhamba kupatsanura (x, y): dzoka x / y kudhindisa ("Sarudza oparesheni.") pirinda ("1.Add") kudhinda ("2.Subtract") kudhinda ("3.Multiply") kudhinda ("4.Divide")