100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Summary

Summary data types in python

Rating
-
Sold
-
Pages
5
Uploaded on
17-07-2024
Written in
2023/2024

this documentation helps to learn the data types in python

Institution
Course









Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
Course

Document information

Uploaded on
July 17, 2024
Number of pages
5
Written in
2023/2024
Type
Summary

Subjects

Content preview

Data types in python




Integer Data Types in Python
In Python, integers are whole numbers, positive or negative,
without decimals, of unlimited length.

Declaring an Integer

To declare an integer, simply assign a whole number to a
variable.

x = 10
Integer Operations

Python supports various mathematical operations with integers,
such as addition, subtraction, multiplication, and division.

x = 10
y = 2

, print(x + y) # prints 12
print(x - y) # prints 8
print(x * y) # prints 20
print(x / y) # prints 5.0
Type Conversion

Python allows converting other data types to integers, using
the int() function.

print(int(3.7)) # prints 3
print(int('5')) # prints 5
Non-decimal Integers in Python
Python supports non-decimal integers, using the 0b prefix for
binary, 0o prefix for octal and 0x prefix for hexadecimal.

Binary Numbers

x = 0b1010 # binary number
print(x) # prints 10
Octal Numbers

x = 0o12 # octal number
print(x) # prints 10
Hexadecimal Numbers

x = 0xA # hexadecimal number
print(x) # prints 10
Converting Base n to Base 10
To convert a number from another base to base 10, use
the int() function with the base specified

Binary to Decimal
$7.99
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached

Get to know the seller
Seller avatar
akashkarthik

Get to know the seller

Seller avatar
akashkarthik K.ramakrishan college of technology
Follow You need to be logged in order to follow users or courses
Sold
0
Member since
1 year
Number of followers
0
Documents
2
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

Frequently asked questions