Jump to content
Addic73d

python question..

Recommended Posts

Din tot ce am citit aici pe forum, am observat ca "python is among us" adica e foarte utilizat ca limbaj de programare, asa ca l-am descarcat, instalat si am zis poate, poate reusesc sa invat ceva.

Acum toate bune pana ajung aici, practic sunt KO, numai inteleg nimic si sper ca cineva sa ma lamureasca.

c1dlw.jpg

Link to comment
Share on other sites


x= int(input("Please enter an integer: "))

if x < 0:
x=0
print ("Negative changed to zero")
elif x==0:
print ("Zero")
elif x == 1:
print ("Single")
else:
print("More")

declara?iile care merg împreun? trebuie s? aib? aceea?i indentare

Edited by pyth0n3
Link to comment
Share on other sites

Codurile alea date ca exmplu pe site sunt scrise direct in interpreter si dupa ce scrii o instructiune if iti apar punctele de suspensie pentru care trebuie sa stabilesti un anumit numar de spatii (apasand space) si apoi sa scrii restul de instructiuni ce fac parte din blocul if, apoi cand vrei sa termini cu if cand iti apar iar punctele de suspensie apesi enter fara sa mai lasi niciun spatiu sau scrii else / elif.

Atunci cand scrii surse e foarte importanta identarea adica acel numar de spatii / tab care trebuie sa-l pui de atatea ori cat este de "adanca" instructiunea, adica:


#! /usr/bin/env python

from sys import argv

def main(args):
x = len(args)
if x > 1:
for i in range(1, x):
print "Argumentul %d %s" % (i, args[i])
else:
print "Executat fara argumente."

if __name__ == "__main__":
main(argv)

Un mic exemplu nu l-am testat daca functioneaza l-am scris direct aici.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...