Sample Code of Python
- Jino Shaji
- Jan 7, 2015
- 1 min read
Updated: Jun 9, 2020
Look at a sample of code Of Python…
x = 34 – 23 # A comment.
y = “Hello” # Another one.
z = 3.45
if z == 3.45 or y == “Hello”:
x = x + 1
y = y + “ World” # String concat.
print x
print y
Enough to Understand the Code
•Assignment uses = and comparison uses ==.
•For numbers +-*/% are as expected.
–Special use of + for string concatenation.
–Special use of % for string formatting.
•Logical operators are words (and, or, not)
not symbols (&&, ||, !).
•The basic printing command is “print.”
•First assignment to a variable will create it.
–Variable types don’t need to be declared.
–Python figures out the variable types on its own
.
Comments