Python Stuff
Python Stuff
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")
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)
Question 13
Enter a value:5
1
2
3
4
5
Question 14
*
* *
* * *
* * * *
Question 15
* * * * *
* * * *
* * *
* *
*