0% found this document useful (0 votes)
0 views3 pages

Python Assignment

The document outlines a Python assignment that includes tasks such as finding the sum of all odd numbers up to 100 and the sum of all digits of a number. It also explains various data types in Python, including strings, numeric types, lists, tuples, dictionaries, sets, booleans, bytes, and NoneType. The assignment is submitted by Julie Gayari, a student in ECE AI 1.

Uploaded by

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

Python Assignment

The document outlines a Python assignment that includes tasks such as finding the sum of all odd numbers up to 100 and the sum of all digits of a number. It also explains various data types in Python, including strings, numeric types, lists, tuples, dictionaries, sets, booleans, bytes, and NoneType. The assignment is submitted by Julie Gayari, a student in ECE AI 1.

Uploaded by

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

PYTHON ASSIGNMENT – 1

2. To find sum of all odd numbers till 100.

4. Explain all the datatypes.


(str)represents textual data, i.e., sequences of Unicode characters.
Text Type: Strings are immutable. Example: "Hello, World!", 'Python'.

Numeric Types: (int) represents integer numbers without a fractional part. Integers
in Python 3 are of unlimited size, limited only by available
memory. Example: 5, -3, 42.
(float) Represents real (floating-point) numbers, i.e., numbers
that may have a fractional part. Example: 3.14, -0.001, 2.0.
(complex) Represents complex numbers, which are numbers with
a real and an imaginary part. Example: 3+4j, -2-3.5j

(List) Ordered collections of items that can be of different types. Lists


are mutable, allowing modification. Example: [1, 2.5, 'Python',
[3, 4]]
Sequence Types: (tuple) Similar to lists, but immutable. Once created, items cannot be
added or removed, and existing items cannot be changed. Example: (1,
'a', 3.14).

(Dict) Represents a dictionary (also known as associative arrays in


other languages) that maps keys to values. Dictionaries are mutable and
Mapping Type: indexed by keys, which can be any immutable type. Example: {'name':
'John', 'age': 30}.

(Set) An unordered collection of unique items. Sets are mutable and


can be used to perform mathematical set operations like union,
intersection, etc. Example: {1, 2, 3, 2} will be {1, 2, 3}.
Set Types:
(frozenset) The immutable version of a set. It can be used as a key in a
dictionary. Example: frozenset([1, 2, 3, 2])
(Bool) Represents a boolean value that can be either True or False.
Boolean Type:
Boolean values are often the result of comparison operations.
(Bytes) An immutable sequence of bytes, often used for binary data.
Example: b'Hello'
(bytearray) A mutable sequence of bytes. It is similar to bytes but
Binary Types: allows modification. Example: bytearray(b'Hello')
(memoryview) A memory view object that allows Python code to
access the internal data of an object that supports the buffer protocol
without copying.
(NoneType) This type has a single value, None, used to signify the
None Type:
absence of a value or a null value.

5. To find the sum of all the digits of a number.


SUBMITTED BY - JULIE GAYARI (48)
ECE AI 1

You might also like