0% found this document useful (0 votes)
19 views24 pages

Python Notes

The document explains various computer number systems including decimal, binary, octal, and hexadecimal, along with methods for converting between these systems. It also provides an overview of Python's built-in data types such as numeric, sequence, set, mapping, boolean, and binary types, with examples of their usage. Additionally, it includes a task to create a dictionary in Python to store employee information.

Uploaded by

sanjana.kirodian
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views24 pages

Python Notes

The document explains various computer number systems including decimal, binary, octal, and hexadecimal, along with methods for converting between these systems. It also provides an overview of Python's built-in data types such as numeric, sequence, set, mapping, boolean, and binary types, with examples of their usage. Additionally, it includes a task to create a dictionary in Python to store employee information.

Uploaded by

sanjana.kirodian
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

Python

Computer number systems are essential for understanding how data is represented and
manipulated within a computer. The most common number systems used in computing are:
1. Decimal (Base 10)
2. Binary (Base 2)
3. Octal (Base 8)
4. Hexadecimal (Base 16)

1. Decimal to Binary
To convert a decimal number to binary, divide the number by 2 and record the remainder.
Repeat the process with the quotient until you get a quotient of 0. The binary number is the
sequence of remainders read from bottom to top.
Example: Convert 25 to binary

2. Binary to Decimal
To convert a binary number to decimal, multiply each bit by 2 raised to the power of its
position from right to left, starting at 0, and sum the results.
Example: Convert 11001 to decimal

3. Decimal to Octal
To convert a decimal number to octal, divide the number by 8 and record the remainder.
Repeat the process with the quotient until you get a quotient of 0. The octal number is the
sequence of remainders read from bottom to top.
Example: Convert 25 to octal
Python

4. Octal to Decimal
To convert an octal number to decimal, multiply each digit by 8 raised to the power of its
position from right to left, starting at 0, and sum the results.
Example: Convert 31 to decimal

5. Decimal to Hexadecimal
To convert a decimal number to hexadecimal, divide the number by 16 and record the
remainder. Repeat the process with the quotient until you get a quotient of 0. The
hexadecimal number is the sequence of remainders read from bottom to top.
Example: Convert 25 to hexadecimal

6. Hexadecimal to Decimal
To convert a hexadecimal number to decimal, multiply each digit by 16 raised to the power
of its position from right to left, starting at 0, and sum the results.
Example: Convert 19 to decimal

7. Binary to Octal
To convert binary to octal, group the binary digits into sets of three starting from the right.
Convert each group to its octal equivalent.
Example: Convert 11001 to octal
Python

8. Octal to Binary
To convert octal to binary, convert each octal digit to its 3-bit binary equivalent.
Example: Convert 31 to binary

9. Binary to Hexadecimal
To convert binary to hexadecimal, group the binary digits into sets of four starting from the
right. Convert each group to its hexadecimal equivalent.
Example: Convert 11001 to hexadecimal

10. Hexadecimal to Binary


To convert hexadecimal to binary, convert each hexadecimal digit to its 4-bit binary
equivalent.
Example: Convert 19 to binary
Python

In Python, there are several built-in data types that you can use to store and manipulate data.
Here is a comprehensive list of the main data types along with examples of how to use them
in Python:
1. Numeric Types
o Integer: int
o Floating point: float
o Complex number: complex
2. Sequence Types
o String: str
o List: list
o Tuple: tuple
o Range: range
3. Set Types
o Set: set
o Frozen set: frozenset
4. Mapping Type
o Dictionary: dict
5. Boolean Type
o Boolean: bool
6. Binary Types
o Bytes: bytes
o Byte array: bytearray
o Memory view: memoryview
Here is a Python script demonstrating the declaration and usage of these data types:

Q. Write a Python program that creates a dictionary to store information about a


employee. The dictionary should include keys for name, age, employee id, and work
load (a list ). Print the dictionary.
Python

Ans:

Python Examples:
Python
Python
Python
Python
Python
Python
Python
Python
Python
Python
Python
Python
Python
Python
Python
Python
Python
Python
Python

You might also like