What is syntax

  • Syntax:

    • A language syntax defines a set of rules that specify a correct computer program.

  • Language syntax elements:

    • Identitifiers:

      • An identifier is a name used to identify a variable, function, class, module or other object.

      • An identifier starts with a letter A to Z or a to z or an underscore (_)

    • Keywords

    • Puntuation symbols

Python keywords (Reserved Words)

  • The following list shows the Python keywords:

       and 	        as 	        assert
       break 	class		continue
       def		del		elif
       else 	except		False
       finally 	for		from
       global 	if		import
       in		is	        lambda
       None 	nonlocal 	not
       or		pass		raise
       return 	True		try
       while 	with		yield 
    

    These are reserved words

    You cannot use them as identifiers

Python execution modes

  • A Python program can be executed in two different modes of execution:

    1. Interactive Mode:

      • Each Python statement is typed in into the Python interpreter interactively

      • The statement typed is executed immediately by the Python interpreter

    2. Script Mode:

      • The Python program is first stored in a script (file)

      • Then the Python program is executed by the Python interpreter