Skip to main content

Variables and Datatype in Python || Python Programming Tutorial 2

Welcome


So today here you are going to learn about variables and different data types in python.


Variables and Datatype in Python
Variables and Datatype in Python


Variables and Datatypes


Python is completely object-oriented and is not "statically typed", So you need not declare variables or there type before using them.
Remember that every variable in python is an object.

Now, let's learn about some basic data types.

Numbers

Python supports two types of numbers: integers and floating types ( It also supports complex numbers which would not be included in this tutorial)

The Syntax for using an integer is:
(Run the code to see the output)



And for using floating-point numbers you may use the below syntax:


Strings

For making strings in python we either use double or single quotes.
For Example:


Note: Remember one thing you could add two numbers or strings, but you could not add a number with a string, however multiplication of a string with a number can be possible

Whenever we add to strings the process is called concatenation, whereas multiplication of string with a number is called replication.

Exercise:

Here is a small exercise for you, here you have to change the value of the variables and put "Hello" as the value of the variable mystr and 7 as the value of the variable myint and 9.99 as the value of the variable myfloat. 
And get the output:
Hello
7
9.99



Click the thumbnail below to watch the full tutorial in Hindi:

Comments

Popular posts from this blog

Decision Making || Python Programming tutorial 4

Welcome So today here you are going to learn decision making in python ( if, elif, if-else, nested if statements in python).  Decision-making statements in programming languages decides the direction of the flow of program execution. Decision-making statements available in python are  if, elif, if-else, nested if. Decision making in python if Statement if statement is the most simple decision-making statement. It is used to decide whether a certain statement or block of statements will be executed or not i.e if a certain condition is true then a block of statement is executed otherwise not. Syntax :     if   condition:             #Statements to execute  Here, conditions after evaluation will be either true or false. if statement accepts boolean values – if the value is true then it will execute the block of statements below it otherwise not. We can use  condition  with bracket ‘( )’ also. Flowchart:  Below we have given a small illustration

Taking input in Python || Comments in Python || Python programming tutorial 3

Welcome So today here you are going to learn how to take input from user in python. Taking input in Python Taking input in Python Developers often have a need to interact with users, either to get data or to provide some sort of result. Nowadays mostly programs use a dialog box as a way of taking input from users. While Python provides us with an inbuilt function to read the input from the keyboard. Note: Here we are talking about methods used in python 3.x input(): This function is used to take input from the users in python 3.x. When input() function executes program flow will be stopped until the user has given input.  The important thing which you have to keep in mind is, Whatever you enter as input, input() function convert it into a string . Even if you enter an integer value still input() function converts it into a string. You need to explicitly convert it into an integer in your code using typecasting. Run the program below and try it yourself.

Python Programming Tutorial 1 || Learn How To Download Python and Your First Hello World Program

Welcome So today here you are going to learn how to download python 3.x and Run your very first python program.