Sitemap
Sumanr Bangera

Sumanr Bangera

A software engineer who is passionate about singing, blog writing, dancing, drawing, and yoga

Python: Day1_Getting started

3 min readNov 6, 2023

COMMENTS

  • Comments start with a #.
  • We can use comments to write an explanation of the code that we have written so that the code can be more readable and understood by another person.
  • The comment will be ignored by the interpreter while executing the Python code.
  • We have single-line comments and multiline comments.

Single line comment: The entire line will be ignored.

Single line comment

Multiline Comment: Multiple lines will be ignored.

One way of multiple comment
Press enter or click to view image in full size
Another way: Python will ignore string literals that are not assigned to a variable, we can add a multiline string (triple quotes) in code, and place the comment inside it

VARIABLES

Variables are like a container which is used to store the values.

Get Sumanr Bangera’s stories in your inbox

Join Medium for free to get updates from this writer.

Variables are case-sensitive. For example, a name is different from a Name or NAME.

Rules to follow for variable names:

  • A variable name must start with a letter or the underscore character

Example: age or _age

  • A variable name cannot start with a number

Example: 10age (which is not acceptable)

gives error
  • A variable name can only contain alpha-numeric characters and underscores (A-z, 0–9, and _ )
  • A variable name cannot be any of the Python Keywords.
gives error

How do you output the variables?

To output the variable we should print() function is used.

Multiple values to Multiple variables:

We can assign multiple values to multiple variables in one line.

1. one line assignment for three variables with the same value, 2. different values stored in one list variable then we can assign it to three separate variables.

Global and Local Variables.

Local variables are declared and used within the function but global variables can be used anywhere and should be declared starting point of the code.

If we try to access the local variable outside the function it will give error.

Press enter or click to view image in full size

LEARNING IS A PROCESS TO UPGRADE YOURSELF AND ENJOY THE PROCESS……

-Suman R Bangera

--

--

Sumanr Bangera
Sumanr Bangera

Written by Sumanr Bangera

A software engineer who is passionate about singing, blog writing, dancing, drawing, and yoga