CLASS 11 PYTHON CODING
1.
x = 10
y=5
print(x + y)
Result:
15
2.
a = 20
b=4
print(a // b)
Result:
5
3.
print("Python" * 3)
Result:
PythonPythonPython
4.
x = 15
if x > 10:
print("High")
else:
print("Low")
Result:
High
5.
for i in range(1, 5):
print(i)
Result:
1
2
3
4
6.
i=1
while i <= 3:
print(i)
i += 1
Result:
1
2
3
7.
a = [10, 20, 30]
print(a[1])
Result:
20
8.
a = [1, 2, 3]
[Link](4)
print(a)
Result:
[1, 2, 3, 4]
9.
d = {"A": 1, "B": 2}
print(d["B"])
Result:
2
10.
d = {1: 'One', 2: 'Two'}
d[3] = 'Three'
print(d)
Result:
{1: 'One', 2: 'Two', 3: 'Three'}
11.
s = "COMPUTER"
print(s[1:5])
Result:
OMPU
12.
print(len("Python"))
Result:
6
13.
t = (5, 10, 15)
print(t[-1])
Result:
15
14.
x=5
y = 10
x, y = y, x
print(x, y)
Result:
10 5
15.
n=5
sum = 0
for i in range(1, n+1):
sum += i
print(sum)
Result:
15