Fetela ho litaba tsa sehlooho

Menehelo

E bonts'a lits'oants'o tse nang le lengolo phetiso

Khoutu ea python e bonolo

Lenaneo lena le bonolo la Python le botsa mosebelisi ho khetha ts'ebetso eo o e batlang. Likhetho tsa likhetho 1, 2, 3 le 4 li nepahetse. Tse peli haeba ... elif ... lipalo tse ling li khethiloe 'me lekala le sebelisoa ho etsa karolo e itseng ea lenaneo. Basebelisi ba hlalositsoeng ke mosebelisi (), fokotsa (), tlatsa (), le karohano () ea ho etsa mesebetsi e nepahetseng.
# Ts'ebetso ena e eketsa linomoro tse peli def eketsa (x, y): Return x + y # Ts'ebetso ena e hatisa linomoro tse peli def subtract (x, y): Return x - y # Ts'ebetso ena e eketsa lipalo tse peli ka makhetlo a mangata ( x, y): Return x * y # Ts'ebetso ena e arola likarolo tse peli tsa karohano ea lipalo (x, y): khutlela x / y hatisa ("Khetha ts'ebetso.") hatisa ("1.Add") khatiso ("2.Subtract") hatisoa ("3.Multiply") khatiso ("4.Divide")