Page 20 - PYTHON-12
P. 20

26.  The following code is supposed to return the longest word in a given list. However, it has syntax and logical
                   errors. Rewrite it after removing all the errors and underline all the corrections made.   (2)

                   def longest_word(words)
                   l_word = ""
                         for in words:

                               if len(word) > len(l_word):
                                    l_word = word
                         return l_word

                   result = longest_word(["information", "management", "functions"])
                   print("The longest word is" result)
               Ans.  def longest_word(words) :

                         l_word = ""
                         for word in words:
                               if len(word) > len(l_word):
                                    l_word = word

                         return l_word
                   result = longest_word(["information", "management", "functions"])
                   print("The longest word is", result)
                27.  (I)  (A)  Which constraint should be applied on a table column so that all values in the column must be
                           unique and must not be NULL?                                                     (2)
                                                             OR
                        (B)  Which constraint should be applied on Username column to ensure that it does not allow duplicate
                           entries but can accept a NULL value?
              Ans.  (A)  Primary Key constraint

                                                             OR
                   (B)  Unique Key constraint
                    (II)  (A)  Write an SQL command to add CHECK constraint(sal_check) to Salary column in a table named
                           STAFF to ensure that all salary values are greater than 30000.
                                                             OR
                        (B)  Write an SQL command to remove CHECK constraint(age_check) from Age column in a table named
                           MEMBERS that limits the values to 18 and above.
              Ans.  (A)  ALTER TABLE STAFF ADD CONSTRAINT sal_check CHECK (Salary > 30000);
                                                             OR
                   (B)  ALTER TABLE MEMBERS DROP CONSTRAINT age_check;
                28.  (A)  List one advantage and disadvantage of Twisted Pair Cable.                        (2)

                                                             OR
                    (B)  What does TCP stand for? Write its functionality.
               Ans.  (A)  Advantage of Twisted Pair Cable: If a portion of a twisted pair cable is damaged, the entire network will
                       not shut down.
                       Disadvantage of Twisted Pair Cable: It easily picks up noise signals which results in higher error rates
                       when the line length exceeds 100 metres.


              A.6    Computer Science–XII
   15   16   17   18   19   20   21   22   23   24   25