Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 141 - 2620_Birla Open Mind C-8
P. 141

    2.  Find errors in the code of the programs given below, correct them.
                                a.  define oddeven(a);
                                    if (a % 2 == 0);
                                        print("even")
                                    else
                                        print("odd")
                                  #calling the function
                                 evenodd(2)
                                 evenodd(3)
                                b.  str = "Orange Education"

                                  count = 0
                                  for i in str;

                                   if( i=='A' or i=='a' or i=='E' or i=='e' or i=='I' or i=='i' or i=='O' or i=='o'
                                   or i=='U' or i=='u'):
                                        count += 1;

                                  print("Total vowels are: " count)
                            3.  Competency-based/application-based questions:
                                a.   Abhimanyu wants to print his name in Python. He noticed that it got printed in lowercase. How
                                  can he change it into uppercase?
                                b.   Your friend Devansh created multiple strings in Python. He now wishes to join the strings to form
                                  a single string. Is this possible? Help him to do so.

                                                                                       21 st
                             DIY In The Lab                                          Century   #Technology Literacy
                                                                                      Skills
                     To
                     Subject   Coding

                       Write a program to:
                       1.  Count the total number of digits in the number 542892 and displays it as output.
                       2.   Type your name in Python and make the first and the last letter of your name uppercase and let the
                         other letters remain lowercase.

                     For The Teacher

                        Demonstration of creating functions to the students.
                        Explain string in detail to the students.

                                                                                          #Functions and Strings in Python 139

| 136 137 138 139 140 141 142 143 144 145 146 |