0% found this document useful (0 votes)
87 views

Assignment 1

Computer Science Python- Class XI

Uploaded by

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

Assignment 1

Computer Science Python- Class XI

Uploaded by

Vishesh Aggarwal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 7
# 1. Write a python script to accept two numbers and display thier addition, difference, difference # remainder and exponent (raise to power). a-eval(input(""Enter the first number : ")) b=eval(input("Enter the second number : ")) print("Addition of "+str(a)+" & "+str(b)+" is "+ str(ab)) print("Subraction of "+str(a)+" & "+str(b)+" is "+ str(a-b)) print("Multiplication of "+str(a)+" & "+str(b)+" is "+ str(a*b)) print("Division of "+str(a)+" & "+str(b)+" is "+ str(a/b)) print("Integer Division of "+str(a)+" & "+str(b)+" is "+ str(a//b)) print("Remainder of "+str(a)+" & "+str(b)+" is "+ str(a%b)) print("Exponent of "+str(a)+" & "+str(b)+" is "+ str(a**b)) Cp Enter the first number : 100 Enter the second number : 5 Addition of 100 & 5 is 105 Subraction of 100 & 5 is 95, ‘Multiplication of 100 & 5 is 500 Division of 100 & 5 is 20.0 Integer Division of 100 & 5 is 20 Remainder of 100 & Sis 0 Exponent of 100 & 5 is 10000000000 #2.. Write a Python script to accept marks in three subjects (out of 100) and display its total mat marks! =eval(input("Enter your marks in Maths(out of 100) : ")) marks2=eval(input("Enter your marks in Seience(out of 100) :")) marks3=eval(input("Enter your marks in English(out of 100) : ")) print) print("Total Marks : "+str(marks1+marks2+marks3)) print("Your percentage is : "+str((marks1+marks2+marks3)/3)) Enter your marks in Maths(out of 100) : 98 Enter your marks in Science(out of 100) : 97 Enter your marks in English(out of 100) : 94 Total Marks : 289 Your percentage is : 96.3333 33333333 43. Write a Python seript to accept principal amount, rate of interest and time in years and displ principal=eval(input("Enter the principal amount : ")) intrest_rate=eval(input("Enter the rate of intrest : ")) time=eval(input("Enter the time(in years) : ")) Si-(principal*intrest_rate*time)/100 print("Simple interest is "+str(S1)) Enter the principal amount : 10000 Enter the rate of intrest : 20 Enter the time(in years) : 3 Simple interest is 6000.0 #4, Write a Python script to accept a number and display square and cube of a number. num-=eval(input("Enter any number : ")) square—num**2 cube=num**3 print("The Square & Cube of "+str(num)+" is "+str(square)+" & "+str(cube)+" respectively.") Enter any number ; 37 The Square & Cube of 37 is 1369 & 50653 respectively. 45, Write a Python script to accept side of a square and display its area and perimeter. side=eval(input("Enter the side of the square : ")) area=side**2 perimeter=4*side print("The Area & Perimeter of "+str(side)+" is "+str(area)+" & "+str(perimeter)+" respectively. Enter the side of the square : 9 ‘The Area & Perimeter of 9 is 81 & 36 respectively. #6. Write a Python script to accept length and breadth of a rectangle and display its area and pe Jength=eval(input(""Enter the length of rectangle : ")) breadth=eval(input(""Enter the breadth of rectangle : ")) area=length*breadth perimeter=2*(length+ breadth) print("The Area & Perimeter of Rectangle is "+str(area)+" & "+str(perimeter)+" respectively.") Enter the length of rectangle : 20 Enter the breadth of rectangle : 30 ‘The Area & Perimeter of Rectangle is 600 & 100 respectively. #7. Write a Python script to accept radius of a circle and display its area and circumference. radius=eval(input(""Enter the radius of the circle : ")) area=(22/7)*(radius**2) circumference=2*(22/7)*radius print("The Area & Circumference of Rectangle is "+str(area)=" & "+str(circumference)+" respec Enter the radius of the circle : 49 ‘The Area & Circumference of Rectangle is 7546.0 & 308.0 respectively. #8. Write a Python script to accept base and height of a triangle and display its area. (Area=1/2* base=eval(input("Enter the base of the triangle : ")) height-eval(input("Enter the height of the triangle : ")) area=(1/2)*base*height print(""The Area of Triangle is "+str(area)) Enter the base of the triangle : 30 ter the height of the triangle : 20 #9. Write a Python script to accept three sides of a triangle and calculateitsareausing Heron's fo # s=(atbtc) /2 A=(s*(s-a)(s-b)(s-c))**(1/2) a=eval(input("Enter the length Ist side of triangle : ")) b-eval(input("Enter the length 2nd side of triangle : ")) c=eval(input("Enter the length 3rd side of triangle : ")) sH(atb+e)/2. #Semi-Perimeter area=(s*(s-a)*(s-b)*(s-c))**(1/2) print("The Area of Triangle is "+str(area)) Enter the length Ist side of triangle : 12 Enter the length 2nd side of triangle : 17 Enter the length 3rd side of triangle : 25, ‘The Area of Triangle is 90.0 # 10.Write a Python script to accept temperature in Fahrenheit and display it in Celsius. # C=(F-32) * 5/9 temp_f+eval(input("Enter the temperature in Fahrenheit : ")) temp_c=(temp_f-32)*(5/9) print("The temperature in C sius is" +str(temp_c)) Enter the temperature in Fabrenbeit : 0 ‘The temperature in Celsius is =17.77777977777778 #11. Write a Python script to accept temperature in Celsius and display it in Fahrenheit. # FHC * 9/5 +32 temp_c=eval(input("Enter the temperature in Celcius :")) temp_f=(temp_e * (9/5)) +32 print("The temperature in Fahrenheit is "+str(temp_f)) Enter 0 ‘The temperature in Fahrenheit is 32.0 #12. Write a Python script to accept time in minutes and display corresponding time in # hours and minutes. Example, if Input is 75 minutes, the output is | hour 15 minutes. time=eval(input("Enter the time(in minutes) : ")) hours-time//60 minutes=time%60_ print("The Time is "+str(hours)+" hour " +str(minutes)+" minute: Enter the time(in minutes) : 145 ‘The Time is 2 hour 25 minutes. #13. Write a Python script to accept the height in inches and display it in feet and inches. height=eval(input("Enter the height(in inches) : ")) feet-height//12 inch=height%12 print("The Height is "+str(feet)+" feet " +str(inch)+" inches.") Enter the height(in inches) : 69 ‘The Height is 5 feet 9 inches. #14, Write a Python script to swap (interchange the value) of two numbers. Display two number num1=eval(input("Enter Ist Number : ")) num2=eval(input(""Enter 2nd Number : ")) print("Memory location of Ist Number :",id(aum1)) print("Memory location of 2nd Number :",id(num2)) #Swapping num! ,num2=num2,num1. print("Ist Number is",num1,"& its memory location is ",id(aum!)) print("2nd Number is",num2,"& its memory location is ",id(num2)) Enter Ist Number : $ Enter 2nd Number : 12 ‘Memory location of Ist Number : 11256192 Memory location of 2nd Number : 11256416 Ist Number is 12 & its memory location is. 11256416 2nd Number is 5 & its memory location is 11256192 # 15, Write a Python script input a number and assign this number to three variables. Display thr num=eval(input("Enter any Number : ")) a-b=c=num print(""Ist Number is",a,"& its memory location is ",id(a)) print("2nd Number is",b,"& its memory location is ",id(b)) print("3rd Number is",c,"®& its memory location is ",id(c)) Enter any Number : 5 Ist Number is 5 & its memory location is. 11256192 2nd Number is 5 & its memory location is 11256192 3rd Number is 5 & its memory location is 11256192 16. Write a Python script to input a string and display it with a # at the end. Input: Courage is grace under Pressure #Output: Courage is grace under Pressure#t string=input("Enter any string : ") print("#"+string #"#") Enter any string : Hello, How are you? ##Hlello, How are you?# 17. Write a Python script to accept marks in five subjects display the following output using a si Example, if the input numbers are 90 70 69 77 99, then output is Mathematics = 90 English = 70 Science = 69 Social Studies = 77 Sanskrit = 99 ml=eval(input("Enter Marks in Mathematics : ")) m2=eval(input("Enter Marks in English : ")) m3=eval(input("Enter Marks in Science :")) m4=eval(input("E : mS=eval(input("Enter Marks in Sanskrit : ")) print("Mathematics = "ml," , English = ",m2," , Science =",m3," , Social Studies =",m4," , Sans Enter Marks in Mathematics : 98, Enter Marks in English : 9 Enter Marks in Science : 99 Enter Marks in Social Studies : 95 Enter Marks in Sanskrit : 98, Mathematics = 98 , English = 9 , Science = 99 , Social Studies = 95, Sanskrit= 98. 18. Write a Python script to accept your name, class, section and display the output in the follow NAME: < yourname> CLASS: < Your class> SECTION: < Your section> section=input("Enter your section: ") print("\nNAME : "+name+"\nCLASS : ",class_,"\t SECTION : "+section) Enter your name: Vishesh Aggarwal Enter your class: 11 Enter your section : H NAME : Vishesh Aggarwal CLASS: Il SECTION: H 19. Write a Python script to display the following message on the screen a) "The professor said, "Please don't sleep in the clas #b) "Opportunities don't happen. You create them." ry not to become a person of "success" but print("""a) "The professor said, "Please don't sleep in the class" ™ print( ) 4b) "Opportunities don't happen, You create them." Try not to become a person of "suc: 4) "The professor said, "Please don't sleep in the class" #b) "Opportunities don't happen. You create them." Try not to become a person of "success" but try to become a pe < » 20. Write a Python script to accept first name, middle name and last name and display the full ne Input: first name is Ankit middle name is Kumar last name is Jain Output: Ankit Kumar Jain f name=input("Enter your First Name : ") m_name=input("Enter your Middle Name : ") |_name=input("Enter your Last Name : ") print("Your name is",f_name,m_name,|_name," Enter your First Name : Vishesh Enter your Middle Name Enter your Last Name : Aggarwal Your name is Vishesh Aggarwal 21. Write a Python script to accept your name and a number. Display your name so many times « Input: Name is Ankit Number is 3 Output: AnkitAnkitAnkit name=input("Enter your Name : ") num=eval(input(""Enter a number : ")) print(name*num) Enter your Name : Vishesh Enter a number : 4 Vishesh Vishesh Vishesh Vishesh 22, Write a Python script to accept five subjects you have taken in class 11 and display all the su Input ENGLISH, MATHS, PHYSICS, CHEMISTRY, COMPUTER SCIENCE Output ENGLISH*MATHS*PHYSICS*CHEMISTRY*COMPUTER SCIENCE sub1=input("Enter your Ist Subject :") sub2=input("Enter your 2nd Subject : ") sub3input("Enter your 3rd Subject :") sub4=input("Enter your 4th Subject : ") subS=input("Enter your Sth Subject : ") print(sub 1, sub2,sub3,sub4,sub5,sep=" *") Enter your Ist Subject : Eng Enter your 2nd Subject : Maths Enter your 3rd Subject : Phy Enter your 4th Subject : Chem Enter your Sth Subject : CS. Eng * Maths * Phy * Chem * C.S. Colab paid products - Cancel contracts here

You might also like