python (2)
python (2)
if x < y:
print(“x is less than y”)
Things to Remember
elif x > y: • Tabs and new lines are used to denote the end of commands and
print(“x is greater than y”) functions, no semicolons here!
else: • Python uses colons similar to the way we use open curly braces
print(“x is equal to y”)
({) in C, but these should be on the same line as the code, not a
line all by themselves.
import sys • Python is a dynamically typed language, meaning it infers data
types at the time of assignment. + acts as both arithmetic addition
for s in sys.argv: and string concatenation depending on the variable types.
print(s) • Python comes with more functions out of the box than C. Ad-
ditionally, there are lots of libraries that exist for Python so it is
typically a good idea to check if functions exist in Python’s many
libraries before you implement them yourself.
© 2018 This is CS50.