Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Class notes

Data types

Rating
-
Sold
-
Pages
6
Uploaded on
10-12-2024
Written in
2024/2025

Lecture notes of 6 pages for the course GE3171 at RAMCO INSTITUTE OF TECHNOLOGY (Python data types)

Institution
Course

Content preview

Values and Types: int, float, boolean, string, and list

Values

Value can be any letter, number or string.

For e.g., Values are 2, 42.0, and 'Hello, World!'. (These values belong to different data types.)

Python Data Types

Variables can hold values, and every value has a data-type. Python is a dynamically
typed language; hence we do not need to define the type of the variable while declaring it.
The interpreter implicitly binds the value with its type.

a=5

The variable a holds integer value five and we did not define its type. Python
interpreter will automatically interpret variables a as an integer type.

Python enables us to check the type of the variable used in the program. Python
provides us the type() function, which returns the type of the variable passed.

Consider the following example to define the values of different data types and
checking its type.

1. a=10
2. b="Hi Python"
3. c = 10.5
4. print(type(a))
5. print(type(b))
6. print(type(c))




Standard data types

A variable can hold different types of values. For example, a person's name must be
stored as a string whereas its id must be stored as an integer.
Python provides various standard data types that define the storage method on each of
them. The data types defined in Python are given below.
 Numbers
 Sequence Type
 Boolean
 Set
 Dictionary

, Numbers
Number stores numeric values. The integer, float, and complex values belong to a
Python Numbers data-type. Python provides the type() function to know the data-type of the
variable. Similarly, the isinstance() function is used to check an object belongs to a particular
class.
Python creates Number objects when a number is assigned to a variable. For example;
a=5
print("The type of a", type(a))

b = 40.5
print("The type of b", type(b))

c = 1+3j
print("The type of c", type(c))
print(" c is a complex number", isinstance(1+3j,complex))




Python supports three types of numeric data.
 int - Integer value can be any length such as integers 10, 2, 29, -20, -150 etc. Python
has no restriction on the length of an integer. Its value belongs to int
 float - Float is used to store floating-point numbers like 1.9, 9.902, 15.2, etc. It is
accurate upto 15 decimal points.
 complex - A complex number contains an ordered pair, i.e., x + iy where x and y
denote the real and imaginary parts, respectively. The complex numbers like 2.14j,
2.0 + 2.3j, etc.

Written for

Institution
Course

Document information

Uploaded on
December 10, 2024
Number of pages
6
Written in
2024/2025
Type
Class notes
Professor(s)
Vetrivel
Contains
Python programming

Subjects

$10.99
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
prasitha510

Get to know the seller

Seller avatar
prasitha510 RAMCO INSTITUTE
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
1 year
Number of followers
0
Documents
1
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions