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
Summary

Summary - Computer science

Rating
-
Sold
-
Pages
8
Uploaded on
08-12-2025
Written in
2025/2026

This documents explain the variable used in python and it’s type with some programs explaining the variables.

Institution
Course

Content preview

VARIABLES & TYPES
A variable is a container that stores values that we can access or change.
A variable has been derived from a word “vary” which means it keeps changing
during the execution of a program.
A variable is stored in the computer's memory. Every variable has a type,
and this type defines the format and behaviour of the variable.
For example,
x=3
it will automatically assign a value of 3 to a variable named x, which is an
integer.
A variable has three main components:
● Identity of the variable
● Type of the variable
● Value of the variable
Identity of the variable:
It refers to the variable’s address in the memory which doesn’t change once it
has been created. The address of an object can be checked using the method
id(variable).
Syntax: >>>id(variable)




Type of a variable:
By type we refer to the data type of the variable.
Python can easily differentiate one data type from another when we write and
run the statement.
Types of data type:
1. Number: Number data type stores numerical value. Python supports
three built-in numeric data types: - integer/long, floating point number
and complex number.

, 2. Int(integer): Integer represents the whole number without any fractional
part. They can be positive or negative and have unlimited size in python.
Example:- -6,567,4,0 etc
3. Float(floating point number) : floating point numbers are written with a
decimal point that separates the integer from the fractional number.
Example:- 3.14, 6.0, -45.3,2887.6 etc.
4. Complex numbers: complex numbers in python are made up of pairs of
real and imaginary numbers. They take the form ‘x+yj’ where ‘x’ and ‘y’
are the real part and j represents the imaginary part. Example:- 2+5j print
(x.real , x.imag).
5. str (string) : A string is a sequence of characters that can be a
combination of letters, numbers and special symbols , enclosed within
quotation marks, single or double or triple (‘ ‘ or “ “ or ‘“ “‘) . Example :-
str=“ Hello Python”
print(str)
Output - Hello Python
6.bool(Boolean) : Boolean data type reprints one of the two possible values,
True or False . A Boolean true value is non-zero, non-null and non-
empty.
Example:- bool_1= (6>10)
Print(bool_1) output - false
7. None: This is a special data type with a single value . Python doesn't
display anything when we give a command to display the value of a variable
containing value as None. On the other hand, None will be displayed by
printing the value of the variable containing None using print( ) statement.


type( )
To determine the type of a variable , i.e., what type of value does it hold then
type( ) function is used.

Written for

Institution
Secondary school
Course
School year
5

Document information

Uploaded on
December 8, 2025
Number of pages
8
Written in
2025/2026
Type
SUMMARY

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
sakshibhola

Get to know the seller

Seller avatar
sakshibhola Vanasthali Public School
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
4 months
Number of followers
0
Documents
3
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

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