Page 30 - AI
P. 30

28. What is the output of 40==40.0?
                  (i)  True               (ii)  False             (iii)  Not Equal       (iv)  Negative
               29. P = 100, RI = 5, T = 2
                  I = (*P*RI*T) / 100
                  Print (“Simple Interest is”, I)
                  What is the correct extension for Python files?
                  (i)  .pt                (ii)  .py               (iii)  .ppt            (iv)  .pyt

               30. What is the correct way to create a function in Python?
                  (i)  def myFunction():                          (ii)  createmyFunction():
                 (iii)  openmyFunction():                         (iv)  declmyFunction():
               31. What is used to remove any whitespace from both the beginning and the end of a string?
                  (i)  clear()            (ii)  del()             (iii)  strip()         (iv)  trim()
               32. What is used to replace parts of a string?
                  (i)  rec()              (ii)  replace()         (iii)  switch()        (iv)  change()
               33. Which of these is a dictionary?
                  (i)  ("tomato", "potato", "onion")              (ii)  {"tomato", "potato", "onion"}
                 (iii)  ["tomato", "potato", "onion"]             (iv)  {"name": "tomato", "color": "red"}
               34. How do you start a while loop in Python?
                  (i)  while x>y:         (ii)  x>y {}            (iii)  while (x>y)     (iv)  while {x>y}
               35. What is used to stop a loop?
                  (i)  break              (ii)  stop              (iii)  exit            (iv)  clear
               36. We have a set x = {1,2,3,4}, and we execute x.remove(10). What will happen?
                  (i)  Key error is raised                        (ii)  All are removed as 1+2+3+4=10
                 (iii)  No exception is raised                    (iv)  Method not executed
               37. What is the output of the following code?
                  eval(''2 + 4 * 2'')
                  (i)  10                 (ii)  8                 (iii)  12              (iv)  2

               38. How do you draw a rectangle centred at 10,10 with width and height as 20, 30 respectively?
                  (i)  Canvas.create.rectangle{10,10,20,30}
                  (ii)  Canvas_create_rectangle(10,10,20,30)
                 (iii)  Canvas.createrectangle{10,10,20,30}
                 (iv)  Canvas.create_rectangle(10,10,20,30)
               39. #!/usr/bin/python
                  str = "this book on artificial intelligence is great";
                  print "str.capitalize() : ", str.capitalize()
                  What is the output?
                  (i)  str.capitalize() : This book on artificial intelligence is great
                  (ii)  str.capitalize() : this book on artificial intelligence is great
                 (iii)  this book on artificial intelligence is great
                 (iv)  str.capitalize() : This Book On Artificial Intelligence Is Great
               40. def printme( str ):
                  "Prints the passed string into the function"
                  print str
                  return;
                  printme("This book is great")
                  (i)  This book is great
                  (ii)  This Book Is Great
                 (iii)  Print(This book is great)
                 (iv)  Print.This book is great



             ArtificiAl intelligence                                                                         29
   25   26   27   28   29   30   31