Class VIII Python Programs
Class VIII Python Programs
if a>0:
print("Positive")
else:
print("Negative")
Q. 2 Write a Python program to check whether a user given character is a vowel or consonant.
print("Vowel")
else:
print("Consonant")
Q. 3 Write a Python program to check whether a number given by user is an even or odd
number.
if a%2==0:
print("Even")
else:
print("Odd")
Q. 4 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.
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. 5 Write a Python program to print the sum of 10 numbers entered by the user.
Ans sum=0
sum=sum+n1
Q. 6 Write a Python program to print all the even numbers in the range entered by the user.
if i%2==0:
print(i)
Q. 7 Write a Python program to print all the odd numbers in the range entered by the user.
if i%2!=0:
print(i)
Q. 8 Write a Python program to print Fibonacci series. [A Fibonacci series looks like 0, 1, 1, 2,
3, 5, 8, 13,…….]
Ans n=int(input("Enter the number of terms you want to print in the Series"))
a=0
b=1
print(a,b)
for i in range(1,n+1,1):
c=a+b
a=b
b=c
print(c)
Q. 9 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 be divided into three frames. Each frame should display three
different pages as mypage1.html, mypage2.html and mypage3.html.
4. There should be a “NEXT” hyperlink created on the top of the page using which you
can switch to another web page “NewWebPage.html”.
Ans <HTML>
<STYLE TYPE="TEXT/CSS">
body{background-color:orange;color:brown}
</STYLE>
</HEAD>
<BODY>
<A HREF="NewWebPage.html">NEXT</A>
<A HREF
</BODY>
</HTML>