Friday, 13 August 2010

Indentation levels and scope (Python)


hey there. i'm going through tutorial on python , programming beginners, have been following until having trouble understanding mean 'indentation level' here:


i want double check understand mean 'indentation level'.
talking line spaces between lines of code (as in space between 2 lines) or how far inside line code indented? or both?
 

code:
  z = 5    def f(x):  return x + z    print(f(3))  
i check tutorial doing because posted above should code below.

code:
  z = 5    def f(x):      return x + z    print(f(3))  
when writing functions in languages java or c++, statements belonging function grouped { }.

code:
  void myfunction()  {       //do  }  
however, python uses indention instead of {} group statements belonging function function

code:
void myfunction():      //do something
 


Forums Macs Mac Programming


  • iPhone
  • Mac OS & System Software
  • iPad
  • Apple Watch
  • Notebooks
  • iTunes
  • Apple ID
  • iCloud
  • Desktop Computers
  • Apple Music
  • Professional Applications
  • iPod
  • iWork
  • Apple TV
  • iLife
  • Wireless

No comments:

Post a Comment