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

Programs Week 1

The document demonstrates various operators in Python, including arithmetic, relational, logical, and assignment operators with examples. It also covers basic data types such as integers, floats, strings, booleans, lists, tuples, dictionaries, and sets, providing type information for each. Each section includes print statements to display the results of operations and data types.

Uploaded by

maryalaapoorva
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)
7 views3 pages

Programs Week 1

The document demonstrates various operators in Python, including arithmetic, relational, logical, and assignment operators with examples. It also covers basic data types such as integers, floats, strings, booleans, lists, tuples, dictionaries, and sets, providing type information for each. Each section includes print statements to display the results of operations and data types.

Uploaded by

maryalaapoorva
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

1.

Demonstration of Operators

a = 10

b=5

# Arithmetic Operators

print("Addition:", a + b)

print("Subtraction:", a - b)

print("Multiplication:", a * b)

print("Division:", a / b)

print("Modulus:", a % b)

print("Exponent:", a ** b)

# Relational Operators

print("a > b:", a > b)

print("a < b:", a < b)

print("a == b:", a == b)

print("a != b:", a != b)

# Logical Operators

print("Logical AND:", a > 5 and b < 10)

print("Logical OR:", a < 5 or b < 10)

print("Logical NOT:", not(a > b))

# Assignment Operators

x=5

x += 3

print("Assignment (+=):", x)

[Link] Data Types in Python


#Integer

a = 10

print("Integer:", a, type(a))

#Float

b = 10.5

print("Float:", b, type(b))

#String

c = "Hello Python"

print("String:", c, type(c))

#Boolean

d = True

print("Boolean:", d, type(d))

#List

e = [1, 2, 3, 4]

print("List:", e, type(e))

#Tuple

f = (10, 20, 30)

print("Tuple:", f, type(f))

#Dictionary

g = {"name": "John", "age": 21}

print("Dictionary:", g, type(g))
#Set

h = {1, 2, 3, 4}

print("Set:", h, type(h))

You might also like