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

Python Stuff

The document contains a series of Python programming questions and their corresponding code snippets. It includes examples of checking if a number is even or odd, determining leap years, calculating sums of odd and even numbers, and printing multiplication tables. Additionally, it demonstrates how to calculate average marks and print patterns using nested loops.

Uploaded by

aarts1902
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views3 pages

Python Stuff

The document contains a series of Python programming questions and their corresponding code snippets. It includes examples of checking if a number is even or odd, determining leap years, calculating sums of odd and even numbers, and printing multiplication tables. Additionally, it demonstrates how to calculate average marks and print patterns using nested loops.

Uploaded by

aarts1902
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

Question 6

1 num = int(input("Enter a number : "))


2 if num==0:
3 print("The number is zero")
4 else:
5 if numt2==0:
6 print("The number is even")
7 else:
8 print ("The number is odd")

Enter a number : 98
The number is even

Question 7
1 year = int(input (""Enter the year : "))
2 if year % 4==0:
3 if year%100=0:
4 if year%400 == 0:
5 print(year, "is a leap year")
6 else:
7 print (year, "is not a leap year")
8 else:
9 print(year, "is a leap year")
10 else:
11 print (year, "is not a leap year")

Enter the vear : 1008


1000 is not a leap year

Question 8
1 sum1=0
2 for i in range(1, 15) :
3 if i%2!=0:
4 sum1 += i
5 print (sum1)

49

Question 9
1 sum1=0
2 for i in range(1, 21):
3 if i%2==0:
4 sum1 += i
5 print(sum1)

110

Question 10
1 firstName="Philip
2 lastNane="Jason"
3 fulIName=firstName + lastNane
4 print(fullName)

Philip Jason

Question 11
1 num = int (input( "Enter a number : "))
2 for i in range (1, 11) :
3 print (num,"*",i, "=", num*i)
Enter a number : 5
5 * 1 = 5
5 * 2 = 10
5 * 3 = 15
5 * 4 = 20
5 * 5 = 25
5 * 6 = 30
5 * 7 = 35
5 * 8= 40
5 * 9= 45
5 * 10 = 50

Question 12
1 l=[]
2 for i in range(5) : #range is till 5 as we are taking the markS of 5 subjects
3 m = float (input("Enter the marks : "))
4 l.append (m)
5 sum1 = 0
6 for i in l:
7 Sum1+i
8 avg = sum1/5
9. print("The average marks are :", avg)

Enter the marks : 99


Enter the marks : 98
Enter the marks : 97
Enter the marks: 92
Enter the marks : 91
The average marks are : 95.4

Question 13

1 n=int (input ('Enter a value:))


2 i=1
3 while i<=n:
4 print(i)
5 i=i+1

Enter a value:5
1
2
3
4
5

Question 14

1 for i in range (5):


2 for j in range(i):
3 print('**, end=' ')
4 print()

*
* *
* * *
* * * *
Question 15

1 for i in range(5,i, -1):


2 for j in range(5,i,-1):
3 print('*', end=' ')
4 print()

* * * * *
* * * *
* * *
* *
*

You might also like