assignment
assignment
Tuples are immutable because once a tuple is created, its elements cannot
be changed, added, or removed. This behavior ensures that the data In
tuples remains constant throughout the program.
//: Floor division operator, returns the largest integer less than or equal to the
division result.
Example: 7 // 2 = 3.
Example: 2 ** 3 = 8.
Example: 7 % 2 = 1.
Q3. Explain variable in Python with its rules and conventions for declaration.
Scientific computing.
Game development.
Python has a simple and straightforward syntax that closely resembles the
English language. This makes it easy for beginners to learn and write Python
programs. For example:
Print(“Hello, World!”)
2. Interpreted Language:
Example:
X = 10
Y=5
Print(x + y)
3. Portability:
Python is platform-independent, which means a Python program written on
one operating system (e.g., Windows) can run on another (e.g., Linux,
macOS) without modification. This portability makes Python highly versatile
for cross-platform applications.
Python provides a rich set of libraries and modules that can be imported to
simplify tasks. For example:
These libraries eliminate the need to write complex code from scratch.
Python supports a variety of data types, each suited for different use cases.
Below is a list and explanation of commonly used data types:
1. Int (Integer):
Example:
X = 10
Y = -5
Example:
Pi = 3.14
3. Str (String):
Example:
Name = “Python”
4. List:
Represents an ordered collection of items, which can be of different types.
Lists are mutable, meaning their elements can be modified.
Example:
Numbers = [1, 2, 3, 4]
Numbers.append(5)
5. Tuple:
Similar to lists but immutable. Useful when data should not be modified.
Example:
Print(coordinates[0]) # Output: 10
6. Dict (Dictionary):
Example: