Anil 1
Anil 1
Anil 1
PRINT To print personal information like Name, Father’s Name, Class, School Name.
print(“*”)
print(“* *”)
print(“* * *”)
print(“* * * *”)
print(“* * * * *”)
print(“* * * * *”)
print(“* * * *”)
print(“* * *”)
print(“* *”)
print(“* ”)
2. Write python code to find square of number 7
Ans
num = int(input("enter your number = "))
square = num*num
print(“square of number =”, square)
print(num[2:5:1])
print(num[-2:-5:-1])
• Create a list of first 10 even numbers, add 1 to each list item and print the final list.
• Create a list List_1=[10,20,30,40]. Add the elements [14,15,12] using extend function.
• Now sort the final list in ascending order and print it.
even = [2,4,6,8,10,12,14,16,18,20]
value=1
list2=[]
for i in even:
list2.append(i+value)
print("Final List: ",list2)
List_1=[10,20,30,40]
List_1.extend([14,15,12] )
print(List_1)
List_1.sort()
print(List_1)
• Program to check if a person can vote
IF, age = int(input("enter your age ="))
FOR, if age>=18:
print("you are eligible for vote")
WHILE
else:
print("you are not eligible for vote")
• Input a number and check if the number is positive, negative or zero and display
an appropriate message
num = int(input("enter a number ="))
if num>0:
print("Number is positive")
elif num==0:
print("number is zero")
else:
print("number is negative")
• To print first 10 natural numbers
for i in range(1,11,1):
print(i)