1.4. Java & Python Basics (1)
1.4. Java & Python Basics (1)
OF
COMPUTATIONAL
THINKING AND PROGRAMMING
Java & Python – The basics
Learning Objectives
This session will cover:
1. Syntax
2. Keywords
3. Operators
Syntax
An operator in a programming
language is a symbol which can
be used to perform either a
mathematical, relational or
logical operation.
&& and Logical AND 4 > 2 && 8 <= 15 evaluates to true in Java
operator 21 == 25 and 40 == 40 evaluates to false in
Python
|| or Logical OR 27 > 32 || 14 <= 8 evaluates to false in Java
operator 6 <= 15 or 70 != 70 evaluates to true in
Python
! not Logical NOT !(9 > 6) && 5 >= 3 evaluates to false in Java
operator 10 == 10 or not(12 > 11) evaluates to true in
Python
Exercise 2
Expression True/False
30 % 4 <= 2
15 < 10 || 21 != 11
14 > 5 && 8 == 2*4
True && False || 17 >= 17
Summary