Basic Python Syntax and Commands

 

 

 

 

Basic Syntax

Comment the line

# program to create variable "user"

# Short command in spyder, press CTRL+1 to comment the line

Syntax to create new Variable “user”

 

user ="Amit"

# print to check the output of new variable

print(user)

Variables

  • Every variable name can consist letters, numbers and underscore
  • No other type of special character should used
  • May not start with Number

 

# Few examples of variables

user_name="Amit"

userid=23456

user5=234

message="Enter your user name here"

myid=user5

# Invalid variable name

5username= "Vijay"

[email protected]="vijay"

 

  • Assignment
    • Create two variable by name “A” and “B” for doing below activity
      • Sum
      • Multiply
      • Percentage
    • Each activity should give result with help of “print” command.
Code Calibre