Class 12th sumita arora solutions || Chapter 1- Python Revision tour - 1 || Practical
Q. Write a program to print an acrostic poem as shown below :-
In the output you need not print bigger letter for P E A C E, but make sure these letters make a vertical word in the output.
Answer =
print("These things I have sPoken unto you,\n that in me yE might have peace.\n In the world ye shAll have tribulation :\n but be good Cheer ;\n I have overcomE the world ")
Q 7 = Write a program to print following ASCII art using print statements :-
(a)
(b)
Answer =
Note :- Make that figure in print statement
like this
print ("--------------- --------------- ")
Q. Write a program to find the side of square whose you read from user .
Answer =
per = float (input("Enter the perimeter of square :- "))
print ("side of square = ", per / 4 )
Q. Write a program to calculate the distance of 1056 feet in term of yards and mile . Given fixed values are 1 mile = 1760yards and 1 yard = 3 feet
Answer =
a = 1056 #given
print ("in yards = ", a/3, "\nin miles = ", a / 3 * 1760)
Q. An athlete is taking rounds of a triangular park with sides as 30 m , 25 m and 35 m . the athlete has 560 m till now. Write a program to print how many rounds of park the athlete has completed.
Answer =
print ("number of rounds :- ",560/(25+30+35))
Q. Write a program that calculate and prints on the screen the number of seconds in a year.
Answer =
print ("number of seconds in year :- ", 60 * 60 * 24 * 365)
Q. Write a program that print a table on two column : on the left the integer temperatures between 0 and 100 (Fahrenheit) and in the right column the corresponding Celsius values.
Answer =
print ("Celcius | Fahrenheit ")
for i in range (1, 101):
print ( i , end= "\t" )
print ("|",end = "\t")
print (9/5*i+32)
Q. Write a program to print the following pattern :-
********
*
*
*
*
*
********
Answer =
for i in range (8): for j in range(8): if i == 0 or i == 7 : print("*",end=" ") elif j == 8 - i : print("*",end=" ") else : print(" " , end = " ") print()
Q. Write program that generate each of the patterns given below :-
(a)
**********
*********
********
*******
******
*****
****
***
**
*
(b)
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
(c)
**********
**** ****
*** ***
** **
* *
* *
** **
*** ***
**** ****
**********
**** ****
*** ***
** **
* *
* *
** **
*** ***
**** ****
**********
Answer =
#(a)
for i in range ( 10 ) :
print ( "* " * ( 10 - i ) )
#(b)
for i in range ( 10 ) :
if i >= 5 :
print ( " * " * 5)
elif i <= 5 :
for j in range(5):
if j == 4 :
print ( " * " * 5)
else :
print(" ",end="")
print()
#(c)
for i in range (10 ):
for j in range(10):
if i < 5 :
if j < 5 - i or j > 4 + i :
print("*",end="")
else :
print(" ",end = "")
else :
if j < i - 4 or j > 13 - i :
print("*" , end="")
else :
print(" ",end = "")
print()
No comments:
Post a Comment