CBSE CS and IP

CBSE Class 11 & 12 Computer Science and Informatics Practices Python Materials, Video Lecture

Revision of basics of Python (3 Marks Questions)


  1. Find the output of the following :
    Text = "gmail@com"
    L = len(Text)
    nText = ""
    for i in range (0,L):
      if Text[i].isupper():
      nText = nText + Text[i].lower()
    elif Text[i].isalpha():
      nText = nText + Text[i].upper()
    else:
      nText = nText + '#&'
    print(nText)
    
  2. Find the output of the following:
    i)  x = "abcdef"
         i = "a"
        while i in x:
            print('i', end = " ")
    
    ii) d = {0: 'a', 1: 'b', 2: 'c'}
          for i in d:
                print(i)
    
    iii) d = {0: 'a', 1: 'b', 2: 'c'}
           for x, y in d:
                  print(x, y)
    
  3. Write a program that rotates the elements of a list so that element at the first index moves to the second index, the elements in the second index move to the third index…... and the last index element should move to the first index.

No comments:

Post a Comment