Page 335 - AI Ver 1.0 Class 9
P. 335

C.  Write Python code for the give instructions.

               1.  Input three angles and check whether they form a triangle or not.
               2.  Input the temperature in Fahrenheit and change into degrees.

               3.  Input time in seconds and change it into minutes.
               4. Find the result of 22/7 * 5 * 5 i.e. the area of circle having radius as 5         [CBSE Handbook]
               5.  Input length and breadth and display whether it is a square or not.

               6.  Input a number between 1 and 7 and display the weekday based on the number entered.
               7. Take a Boolean value “False” and a float number “15.6” and perform the AND operation on both.   [CBSE Handbook]
               8.  Input Salary and Years of Service. If the number of years are more than 5 then give an extra bonus of 15%. Display the
                  net salary after adding the bonus.

               9. Take a string “Zero” and a Boolean value “True” and try adding both by using the Bool () function.   [CBSE Handbook]
               10.  Input a billing amount of shopping done. If the amount is more than 5000 then give a discount of 10%. Display the net
                  billing amount after the discount.
               11.  Input a year and check whether it is a leap year or not.

               12. Take a Boolean value and add a string to it.                                      [CBSE Handbook]
               13. Take a string “Morning “and the float value “90.4” and try and add both of them by using the float () function.
                                                                                                     [CBSE Handbook]







                             Lab                                                                      Computational Thinking



                     1.   Write an algorithm for calculating Net salary of a person (Net Salary=Basic + Allowances – Deductions).
                        Take the Basic, Allowances and Deductions as input.
                     2.   Write an algorithm to print larger of the two marks taken as an input. Also draw a flowchart.
                     3  Write a Python program to:
                        a.  Convert Celsius to Fahrenheit using the formula: (Celsius * 1.8) + 32

                        b.  Input five names from the user and print them in the same line with a single space.
                        c.  Swap the values of two variables using third variable.
                        d.  Convert kilometre unit to metre.
                        e.  Calculate the area of a square.
                        f.  Interchange the values of the adjacent elements of the list. Print the updated list.

                        g.   Input five names of cities in a list. Accept a name and check whether it exists in a list or not. Display
                           appropriate message.
                        h.  Input five subject’s marks in a list and print the percentage of all.
                        i.  Create a list with heterogeneous values and print the values which are only integer.
                        j.  Create a list of five subject’s marks and print the marks >50.






                                                                                Introduction to Python  333
   330   331   332   333   334   335   336   337   338   339   340