Basic Syntax and Semantics
Basic Syntax and Semantics
Computational Thinking
Module 3 :
Basic syntax and semantics
Computational Programming
Thinking Run on
Syntax
Semantics
main computation
variables
• Using the input radius, we can compute circumference
and area
• Note: = is not equal sign! It is an “assignment operator” in
most programming languages to assign values to variables
Module 3 : Basic syntax and semantics 14 of 34
Terminology #7) Print results
Indentation: 1 level
2 levels
+ - * ** / // %
<< >> & | ^ ~
< > <= >= == !=
‘ “ # \ _
( ) [ ] { } @
, : . ` = ;
+= -= *= /= //= %=
&= |= ^= >>= <<= **=
Syntax error:
Python cannot
translate the code
Module 3 : Basic syntax and semantics 32 of 34
Take Home Messages
• Semantics – Meaning of your program
• Syntax – Specifying your algorithm using the
programming language
• This module is about terminologies and syntax:
Statements, statement continuation, modules,
comments, whitespace, indentation, tokens
(keywords, operators, punctuators and
delimiters, literals), functions, expression,
interpreter errors
• Side effects and returns (statement VS expression)