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 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

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

Written for

Institution
Course

Document information

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

Subjects

$8.49
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
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
-
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

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