Professional Documents
Culture Documents
Python #1: Let's Get Started
Python #1: Let's Get Started
One
LANGUAGE TODAY DEVELOPERS PROBLEMS. PROTOTYPING
AND REAL-WORLD
APPLICATIONS
Language,
Many Uses SUPPORTS SUPPORTS APPS, ONE LANGUAGE,
WINDOWS, EV3, ARDUINO, MULTIPURPOSE
LINUX, MACOS, RASPBERRYPI AND USE
UBUNTU OTHER
ARCHITECTURE MICROCONTROLL
ERS.
Syntax similar to English language
Less Code
Interpreted at runtime
Python: More reasons to learn
Quiz
Which popular products are build using Python?
Let’s learn how
to print on
console
Print Syntax
print(message)
" "are used
because we
are printing
a string
Brackets are required message (characters)
because print is a
function
Print Text
• print("Sarvjeet Herald") Print your name
• Text should be wrapped in Double quotes (")in the print function.
Can you find early indication of error in the editor (before running code)?
Syntax Error
• Incorrect Python Grammar
• Code will not execute
• Tell about error in which line.
• Easy to resolve, just to the line number and fix the issue
Print Quotes
Wrong Way!
print(""Clarks" is a British based international shoe manufacturer")
Correct Way!
Use backslash escapes for printing single quotes in text
print("\"Clarks\" is a British based international shoe manufacturer")
OR
Replace outer double quotes with single quotes
print('"Clarks" is a British based international shoe manufacturer')
Print Quotes
Better Way!
Use of backslash escape makes life more easier
It is also compatible with legacy code
Exercises
• PRINT("I love food")
• Print("I love food")
• Print 6
• Print your address
• Print your height
• Print your phone number without zero
• Print your phone number starting with zero (e.g., 09958590959)
• What is the error?
• SyntaxError: invalid token
• Any idea, why this error?
• Leading zero means you are writing an octal notation and you can't have 9 or 8 in an octal
number.
Print two or more pieces of text
Print your first name and last name on a single line
print("Sarvjeet Herald")
Why is it better?
Databases are Atomic. Indivisible and irreducible token to avoid partial updates.
Makes Create, Read, Update, Delete and Search Faster.
Exercise
• Print in a single line, your:
• First Name
• Last Name
• Age
Print Descriptor “First Name” and Value on a single line separated by colon
print("First Name", "Herald",21.0, sep=":")
Useful when fetching and printing values from database
Different ways to separate text values
Print your first name, last name and age on different lines
print("sarvjeet")
print("herald")
print("21")
• Separator keyword argument can describe how the values should be separated on a
single line e.g., comma separated, colon separated, etc
• Keyword is sep
• Default value of sep is Space
• End keyword argument can describe how the print function should be terminated.
• Keyword is end
• Default value is \n