You are on page 1of 5

Python Data Types

Indentation
Submitted By:
• Gulraiz Khan SP20-BCS-001
• Muhammad Waqas SP20-BCS-024
Introduction
• Python is a dynamically typed language, which means that you don't have to declare the data type of a variable
before using it. Instead, the data type of a variable is inferred from the value that it is assigned. Python supports
various data types, including:
• Numeric Types: These include integers, floating-point numbers, and complex numbers.
• Sequence Types: These include strings, lists, and tuples.
• Boolean Type: This includes the Boolean values True and False.
• Set Types: These include sets and frozensets.
• Mapping Types: These include dictionaries.
• Indentation is an essential aspect of Python syntax. In Python, indentation is used to indicate the block of code that
belongs to a particular statement. For example, in a conditional statement, the block of code that executes if the
condition is True should be indented. Similarly, in a loop, the block of code that executes repeatedly should be
indented.
• Python uses whitespace for indentation, and the amount of whitespace used for indentation should be consistent
throughout the code. The standard indentation is four spaces, but some programmers use two or eight spaces.
• Indentation errors are common in Python and can cause your code to behave unexpectedly. It's important to be
mindful of your indentation and to use a text editor that can help you visualize your indentation.
Difference java and python
1):java is compiled language. 1):python is interpreted language.
2):it is statically type language. 2):it is dynamically language.
3):semicolon is compulsory after each statements. 3):semicolon is optional.
4):complex learn then python. 4):easy to learn and use.
5):it has large number of frameworks. 5):it has lower of frameworks.
6):it is faster. 6):it is slower than java.
7):example=class a 7):example=print(“learn”)
{
p.s.v.m(string[]args)
{
s.o.p(“learn”);
}
Indentation example
• Python: c++:
• for I in range(1,6) for(int i=1;i<=5;i++)
• Print(i) {
• cout<<i<<endl;
• }
• In the python code the block o code that executes the print
(i)statement is indicated by the indentation level.
• In c++ the same code block of code is enclosed in braces{}

You might also like