See Python Magic Power!

herikipaji

JF-Expert Member
Aug 23, 2016
1,198
1,364
Salaam wataalamu!

Cheki hizi Python code ...


def print_two(*args):

arg1, arg2 = args

print "arg1: %r, arg2: %r" % (arg1, arg2)

def print_two_again(arg1, arg2):

print "arg1: %r, arg2: %r" % (arg1, arg2)

def print_one(arg1):

print "arg1: %r" % arg1

def print_none():

print "I got nothin'."

print_two("Lipokera","Kamanzilano")

print_two_again("Lipokera","Kamanzilano")

print_one("First!")

print_none()

Narun na Linux inakubali hivi output ..

arg1: 'Lipokera', arg2: 'Kamanzilano'
arg1: 'Lipokera', arg2: 'Kamanzilano'
arg1: 'First!'
I got nothin'.

Nikirun kwenye Ubuntu tu shida inaanza inaandika hivi..


File "try.py", line 3
arg1, arg2 = args
^
IndentationError: expected an indented block

Inakuaje Linux inakubali safi error ije na Ubuntu tu?
Naona kama maajabu haya au Python inabagua OS?
Mwenye mwanga aniangazie tafadhari.

 
Mkuu we huoni kabisa imekuandikia "IndentationError"?
We utakua uli-copy na ku-paste code bila kuweka Indentation vizuri, hapa naongelea spaces uzipange inavyotakiwa, kama ni tabs weka ili block flani ionekane ipo ndani ya function vizuri.

Kama una run same code bila kubadilisha chochote kile kwenye two different OSes hamna sababu ya kuto-run unless uwe umetumia two different language versions alafu ukawa umeaccess features ambazo zilifutwa au hazipo kwenye version nyingine. Kwa case yako though I'm sure tatizo ni mpangilio tu wa code, python spaces ni kitu cha muhimu sana, zipange vizuri.
 
Ooh! lazy tena kwanini wasema hiyo mtaalamu?
Sio mimi, ni designer wa hiyo Language ndiye aliyeona inatakiwa iwepo language ya wavivu. Haina maana ni kitu kibaya, ni kwamba tu unatumia programming effort ndogo kupata matokeo makubwa.
 
Sio mimi, ni designer wa hiyo Language ndiye aliyeona inatakiwa iwepo language ya wavivu. Haina maana ni kitu kibaya, ni kwamba tu unatumia programming effort ndogo kupata matokeo makubwa.
Hahahaa, ila Python ni balaa yani hata kusoma tu inavutia hata huwi bored.
 
Hahahaa, ila Python ni balaa yani hata kusoma tu inavutia hata huwi bored.
Ni nzuri, inakufundisha na kukulazimisha ujue indentation-kitu ambacho programmers wengine wa lugha zingine wanakichukulia poa wakati kinasaidia kufanya program yako isomeke vizuri.
 
Ni nzuri, inakufundisha na kukulazimisha ujue indentation-kitu ambacho programmers wengine wa lugha zingine wanakichukulia poa wakati kinasaidia kufanya program yako isomeke vizuri.
Ina masheriti kama ya kwa mganga wa kienyeji asee, duu yani had space tab
 
Kwenye Python version 2.7 na 3.X unapotumia standard libraries kwa IO ina tumia import from future
 
Ooh! lazy tena kwanini wasema hiyo mtaalamu?
Si ndio tabia ya wabongo!! Kuli pale bandarini anamtukana meneja kwamba ni kula kulala, yeye kuli ndio mwanaume wa ukweli kwa vile anapata kipato chake kwa kumenyeka kybeba mizigi
 
Hizo code mbona balaa. Tumia code tags na kama huwezi bora u attach file. Kifupi zilivyo hazisomeki!
 
Back
Top Bottom