Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

Q. 1 Write a Python program to add two numbers and show the result.

Ans a=10
b=20
c=a+b
print("The sum of two numbers is ",c)

Q. 2 Write a Python program to show the difference of two numbers.


Ans a=10
b=20
c=a-b
print("The difference of two numbers is ",c)

Q. 3 Write a Python program to show the product of two numbers.


Ans a=10
b=20
c=a*b
print("The Product of two numbers is ",c)

Q. 4 Write a Python program to ask the user's name and greet him 'Good Morning'.
Ans name=input("Enter your name:")
print("Good Morning ",name)

Q. 5 Write a Python program to check whether a number given by user is a positive


or negative number.
Ans a=int(input("Enter any number:")
if a>0:
print("Positive")
else:
print("Negative")

Q. 6 Write a Python program to check whether a person can vote in the election or
not.[age>=18 can vote]
Ans age=int(input("Enter your age "))
if age>=18:
print("You can vote!")
else:
print("You cannot vote!")

Q. 7 Write a Python program to check whether a student is pass in an exam or not.


[marks>40 is pass]
Ans marks=int(input("Enter your marks:"))
if marks>40:
print("Pass")
else:
print("Fail")
Q. 8 Write a Python program to check whether a user given character is a vowel or
consonant.
Ans ch=input("Enter any character:")
if ch=='a' or ch=='e' or ch=='i' or ch=='o' or ch=='u':
print("Vowel")
else:
print("Consonant")
Q. 9 Write a Python program to input two numbers and an operator from the user.
Show the result of calculation on the basis of operator entered by the user.[if
operator is '+' then numbers should be added and result should be displayed, if the
operator is '-' then the difference should be displayed etc.
Ans n1=int(input("Enter first number "))
n2=int(input("Enter second number "))
op=input("Enter any operator ")
if op=='+':
print(n1+n2)
elif op=='-':
print(n1-n2)
if op=='*':
print(n1*n2)
if op=='/':
print(n1/n2)
else:
print("Invalid operator!")

Q. 10 Write a Python program to print the sum of 10 numbers entered by the user.
Ans sum=0
for i in range(1, 11, 1):
n1=int(input("Enter any number "))
sum=sum+n1
print("Sum of 10 numbers ", sum)

Q. 11 Write a Python program to print all the even numbers in the range entered by
the user.
Ans lower_limit = int(input("Enter your lower limit "))
upper_limit = int(input("Enter your upper limit "))
for i in range(lower_limit, upper_limit+1, 1):
if i%2==0:
print(i)

Q. 12 Write a Python program to print all the odd numbers in the range entered by
the user.
Ans lower_limit = int(input("Enter your lower limit "))
upper_limit = int(input("Enter your upper limit "))
for i in range(lower_limit, upper_limit+1, 1):
if i%2!=0:
print(i)

Q. 13 Write an HTML code to create a web page with the following functionalities.
Use of CSS is expected:
1. The background colour of the page should be orange and the text colour
should be brown.
2. The page should have a table with three rows and three columns filled with
the data of your choice.
3. The border of the table should be of blue colour.
4. The page should have an ordered list of names of any five festivals.
5. The page should have an unordered list of the names of five states of
India.

Ans <HTML>
<HEAD><TITLE>Good Morning to All</TITLE>
<STYLE TYPE="TEXT/CSS">
body{background-color:orange;color:brown}
table,td,th{ border:5px solid blue}
</STYLE>
</HEAD>
<BODY>

<TABLE>
<CAPTION>MY TIMETABLE</CAPTION>
<TR> <TH>NAME</TH> <TH>CLASS</TH> <TH>AGE</TH> </TR>
<TR> <TD>RAVI</TD> <TD>VII</TD> <TD>12</TD> </TR>
<TR> <TD>AVI</TD> <TD>VI</TD> <TD>10</TD> </TR>
<TR> <TD>KAVI</TD> <TD>VIII</TD> <TD>14</TD> </TR>
</TABLE>

<OL>
<LI>HOLI</LI>
<LI>DIWALI</LI>
<LI>DUSSEHRA</HI>
<LI>RAKSHABANDHAN</LI>
<LI>MAKAR SAKRANTI</LI>
</OL>

<UL>
<LI>MADHYA PRADESH</LI>
<LI>UTTER PRADESH</LI>
<LI>MAHARASHTRA</HI>
<LI>HARYANA</LI>
<LI>KERALA</LI>
</UL>

</BODY>
</HTML>

You might also like