thesexboy
Distributed System Orchestrator
LEVEL 1
200 XP
Python Variables and Comments
In this tutorial you will learn:
Basics of Python
The first thing that one needs to understand in order to learn any programming language is the answer to the question what is a variable?
1. Variables
Variables are the containers where you store your values. They are essentially places in memory for storing data. These containers have different types for storing different types of data. Commonly used data types and their short hand syntax are:
Integer - Int - For storing numbers such as 1,2,3,4 ….
Float - Float - For storing numbers with a floating points e.g 1.91, 2.32, 5.68 etc
Character - Char - For storing characters e.g ‘a’, ‘b’, ‘c’ etc
String - String - For storing large strings e.g “This is my first python program”
In Python you don’t declare a type ( int, float, string etc ) explicitly. Assigning a value automatically declares a variable for you and the data type is handled by python implicitly.
It doesn’t mean there are no data types in python it’s just that it handled by python implicitly
print
(
type
(
myVariable)
;
#would print int
you can explicitly type cast using
myVariable =
int
(
1
)
Important variable naming rules:
2. Write a comment
# This is a comment
Book traversal links for Python Variables and Comments
In this tutorial you will learn:
- Basics of Python
- Commenting
- Variables
- Commenting
Basics of Python
The first thing that one needs to understand in order to learn any programming language is the answer to the question what is a variable?
1. Variables
Variables are the containers where you store your values. They are essentially places in memory for storing data. These containers have different types for storing different types of data. Commonly used data types and their short hand syntax are:
Integer - Int - For storing numbers such as 1,2,3,4 ….
Float - Float - For storing numbers with a floating points e.g 1.91, 2.32, 5.68 etc
Character - Char - For storing characters e.g ‘a’, ‘b’, ‘c’ etc
String - String - For storing large strings e.g “This is my first python program”
In Python you don’t declare a type ( int, float, string etc ) explicitly. Assigning a value automatically declares a variable for you and the data type is handled by python implicitly.
- myVariable =
1
- myVariable2 =
2
- myCharacter =
‘a’
- myString =
“I am a programmer”
It doesn’t mean there are no data types in python it’s just that it handled by python implicitly
(
type
(
myVariable)
;
#would print int
you can explicitly type cast using
myVariable =
int
(
1
)
Important variable naming rules:
- Alpha-numeric characters and underscores (A-z, 0-9, and _ ) can be used only.
- Variable are case-sensitive ( name and Name are different variables ).
2. Write a comment
# This is a comment
Book traversal links for Python Variables and Comments
- ‹ Python Installation and Setup
- Up
- Python Boolean ›