Tuesday, January 5, 2021

Python - Variables (Day 1)

This is a 100 Days challenge to learn a new language (Python). 100 Days of Code - The Complete Python Pro Bootcamp 

I will post some notes to motivate myself to finish this challenge.


Printing Function



Ex:
# Below are all valid
print("Hello World!")
print('Hello World!')
print("Hello 'World'!")
print('Hello "World"!')

Result:
Hello World! Hello World! Hello 'World'! Hello "World"!



Input Function



Ex:
# Get user input
name = input("What's your name?")
print("Hello " + name + "!")

Result:
What's your name?Frank Hello Frank!




Python Variables



    1. Should not start with a number
    2. Normally, in python, we use '_' (underscores) to separate the words
    3. It is case-sensitive
    4. The valid name should only contain A-z, 0-9, and _.

Ex:
my_name = 'Frank'
name = '1'
Name = '1'
_name = '1'



Python Comment



Using '#' instead of '/' or

Ex:
# This is a comment



Note



Unlike other language, python should not contain unexpected indent.

Ex:
IndentationError: unexpected indent


No comments:

Post a Comment