Python3

Hello everyone, My name is Ganeshemanth. In this Blog I will teach about Python 3 programming language for free of cost. We can learn programming for free. My moto is to share my programming knowledge for free of cost through online Blog. Please refer below for free programming tutorial at free of cost. I will upload pdf soon.


Python is a High level, General purpose, Multi paradigm and Object oriented programming language. Python is invented by Guido Van Rossum. Python was first released in 1990.

                                                               -:Comments:- 

Comments can be used to explain python code, make the code more readable and prevent execution when testing code.

Comments starts with a #, and Python will ignore them: 

Example:- 

#This is a comment.
print("Hello, World!")

Comments can be placed at the end of a line, and Python will ignore the rest of the line:

Example:-

print("Hello, World!") #This is a comment

A comment does not have to be text that explains the code, it can also be used to prevent Python from executing code:

Example:-
#print("Ganeshemanth")
print("Cheers, Mate!")

Multiline Comments

Python does not really have a syntax for multiline comments.

To add a multiline comment you could insert a # for each line:

Example:-

#This is a comment
#written in
#more than just one line
print("Hello, World!")

Since Python will ignore string literals that are not assigned to a variable. You can add a multiline string (triple quotes) in your code, and place your comment inside it:

Example:-

"""
This is a comment
written in
more than just one line
"""
print("Hello, World!")

The string is not assigned to a variable, Python will read the code, but then ignore it, and you have made a multiline comment.

                                    -:Variables:-

Variables are containers for storing data values. Python has no command for declaring a variable. A variable is created the moment you first assign a value to it.

Example:-

x = 5

y = "John"

print(x)

print(y)

Variables do not need to be declared with any particular type, and can even change type after they have been set.

Example:-

x = 4       # x is of type int
x = "Ganeshemanth" # x is now of type str
print(x)

                                    -:Casting:- 

If you want to specify the data type of a variable, this can be done with casting.

Example:-

x = str(3)    # x will be '3'
y = int(3)    # y will be 3
z = float(3)  # z will be 3.0


You can get the data type of a variable with the type() function.

Example:-

x = 5
y = "John"
print(type(x))
print(type(y))

String variables can be declared either by using single or double quotes:

Example:-

x = "John"
# is the same as
x = 'John'

                            -:Case-Sensitive:-
Variable names are case-sensitive.

Example:-

This will create two variables:

a = 4
A = "Sally"
#A will not overwrite a

















































































































Comments

Popular posts from this blog

Bitcoin mining

Unveiling the Art of Intraday Trading: Navigating the High-Stakes World of Day Trading

How to act inspite of your emotions