## GUJARAT TECHNOLOGICAL UNIVERSITY

## DIPLOMA IN ENGINEERING - SEMESTER - II EXAMINATION - SUMMER 2025

| Subject Code: DI02000101                                                                                                             | Subject Code: DI02000101                                                                                                             | Subject Code: DI02000101                                                                                                                                                                                                                                                                                                                               | Date: 04-06-2025                                                                                                                     | Date: 04-06-2025                                                                                                                     |
|--------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------|
| Subject Name: Scripting Language                                                                                                     | Subject Name: Scripting Language                                                                                                     | Subject Name: Scripting Language                                                                                                                                                                                                                                                                                                                       |                                                                                                                                      |                                                                                                                                      |
| Time: 10:30 AM TO 01:00 PM                                                                                                           | Time: 10:30 AM TO 01:00 PM                                                                                                           | Time: 10:30 AM TO 01:00 PM                                                                                                                                                                                                                                                                                                                             | Total Marks: 70                                                                                                                      | Total Marks: 70                                                                                                                      |
| Instructions:                                                                                                                        | Instructions:                                                                                                                        | Instructions:                                                                                                                                                                                                                                                                                                                                          |                                                                                                                                      |                                                                                                                                      |
| 1. Attempt all questions. 2. Make Suitable assumptions wherever necessary.                                                           | 1. Attempt all questions. 2. Make Suitable assumptions wherever necessary.                                                           | 1. Attempt all questions. 2. Make Suitable assumptions wherever necessary.                                                                                                                                                                                                                                                                             |                                                                                                                                      |                                                                                                                                      |
| 3. Figures to the right indicate full marks. 4. Use of simple calculators and non-programmable scientific calculators are permitted. | 3. Figures to the right indicate full marks. 4. Use of simple calculators and non-programmable scientific calculators are permitted. | 3. Figures to the right indicate full marks. 4. Use of simple calculators and non-programmable scientific calculators are permitted.                                                                                                                                                                                                                   | 3. Figures to the right indicate full marks. 4. Use of simple calculators and non-programmable scientific calculators are permitted. | 3. Figures to the right indicate full marks. 4. Use of simple calculators and non-programmable scientific calculators are permitted. |
| 5. English version is authentic.                                                                                                     | 5. English version is authentic.                                                                                                     | 5. English version is authentic.                                                                                                                                                                                                                                                                                                                       | 5. English version is authentic.                                                                                                     | 5. English version is authentic.                                                                                                     |
|                                                                                                                                      |                                                                                                                                      |                                                                                                                                                                                                                                                                                                                                                        |                                                                                                                                      | Marks                                                                                                                                |
| Q.1                                                                                                                                  | (a)                                                                                                                                  | What is Type Casting ? Explain implicit type conversion and explicit type conversion with example.                                                                                                                                                                                                                                                     | 03                                                                                                                                   |                                                                                                                                      |
|                                                                                                                                      | ( અ )                                                                                                                                | ટાઇપ કાGLYPH<c=7,font=/QBCAAA+Lohit-Gujarati>GLYPH<c=8,font=/QBCAAA+Lohit-Gujarati>ટગ શું છે ?  ઉદાહરણ સાથે  implicit  ટાઇપ કGLYPH<c=22,font=/QBCAAA+Lohit-Gujarati>વઝGLYPH<c=25,font=/QBCAAA+Lohit-Gujarati>ન અને  explicit  ટાઇપ કGLYPH<c=22,font=/QBCAAA+Lohit-Gujarati>વઝGLYPH<c=25,font=/QBCAAA+Lohit-Gujarati>ન સમGLYPH<c=28,font=/QBCAAA+Lohit-Gujarati>વો. | ૦૩                                                                                                                                   |                                                                                                                                      |
|                                                                                                                                      | (b)                                                                                                                                  | Explain input and print functions in python with examples.                                                                                                                                                                                                                                                                                             |                                                                                                                                      | 04                                                                                                                                   |
|                                                                                                                                      | ( બ )                                                                                                                                | ઉદાહરણ સાથે  input  અને  print  ફં કશન સમGLYPH<c=28,font=/QBCAAA+Lohit-Gujarati>વો.                                                                                                                                                                                                                                                                          |                                                                                                                                      | ૦૪                                                                                                                                   |
|                                                                                                                                      | (c)                                                                                                                                  | Design and Test Python program to read your name, contact number, email, and birth-date and print those details on the screen                                                                                                                                                                                                                          |                                                                                                                                      | 07                                                                                                                                   |
|                                                                                                                                      | ( ક )                                                                                                                                | તમા% ં નામ ,  સંપકGLYPH<c=25,font=/QBCAAA+Lohit-Gujarati> નંબર ,  ઇમેઇલ અને જGLYPH<c=22,font=/QBCAAA+Lohit-Gujarati>મ તારીખ વાંચવા માટે પાયથોન ,ો-ામ અને પરી0ણ કરો અને તે િવગતો GLYPH<c=8,font=/QBCAAA+Lohit-Gujarati>1ીન પર છાપો.                                                                                                                                                 | િડઝાઇન                                                                                                                                 | ૦૭                                                                                                                                   |
|                                                                                                                                      |                                                                                                                                      | OR                                                                                                                                                                                                                                                                                                                                                     |                                                                                                                                      |                                                                                                                                      |
|                                                                                                                                      | (c)                                                                                                                                  | List out features and application of python.                                                                                                                                                                                                                                                                                                           |                                                                                                                                      | 07                                                                                                                                   |
|                                                                                                                                      | ( ક )                                                                                                                                | પાયથોનની                                                                                                                                                                                                                                                                                                                                                  | િવશેષતાઓ અને ઉપયોગની યાદી બનાવો.                                                                                                               | ૦૭                                                                                                                                   |
| Q.2                                                                                                                                  | (a)                                                                                                                                  | Explain if and if-else statement with a suitable example                                                                                                                                                                                                                                                                                               |                                                                                                                                      | 03                                                                                                                                   |
|                                                                                                                                      | ( અ )                                                                                                                                | યો5ય ઉદાહરણ સાથે  if  અને  if-else statement  સમGLYPH<c=28,font=/QBCAAA+Lohit-Gujarati>વો.                                                                                                                                                                                                                                                                   |                                                                                                                                      | ૦૩                                                                                                                                   |
|                                                                                                                                      | (b)                                                                                                                                  | Describe for loop with an example.                                                                                                                                                                                                                                                                                                                     |                                                                                                                                      | 04                                                                                                                                   |
|                                                                                                                                      | ( બ )                                                                                                                                | ઉદાહરણ સાથે  for  લૂપનું વણGLYPH<c=25,font=/QBCAAA+Lohit-Gujarati>ન કરો.                                                                                                                                                                                                                                                                                      | ૦૪                                                                                                                                   |                                                                                                                                      |
|                                                                                                                                      | (c)                                                                                                                                  | Make a use of any loop to create following pattern in python.                                                                                                                                                                                                                                                                                          |                                                                                                                                      | 07                                                                                                                                   |
|                                                                                                                                      |                                                                                                                                      | $                                                                                                                                                                                                                                                                                                                                                      |                                                                                                                                      |                                                                                                                                      |
|                                                                                                                                      |                                                                                                                                      | $ $ $                                                                                                                                                                                                                                                                                                                                                  |                                                                                                                                      |                                                                                                                                      |
|                                                                                                                                      |                                                                                                                                      | $ $ $ $                                                                                                                                                                                                                                                                                                                                                |                                                                                                                                      |                                                                                                                                      |

$ $ $ $ $

(

ક

)

ે

૦૭

|         | પાયથોનમાં નીચે મુજબ પેટનGLYPH<c=25,font=/QBCAAA+Lohit-Gujarati> બનાવવા માટે કોઈપણ લૂપનો ઉપયોગ કરો.                                                                                                                                                         |    |
|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----|
|         | $  $ $                                                                                                                                                                                                                                    |    |
|         | $ $ $                                                                                                                                                                                                                                     |    |
|         | $ $ $ $                                                                                                                                                                                                                                   |    |
|         | $ $ $ $ $                                                                                                                                                                                                                                 |    |
|         | OR                                                                                                                                                                                                                                        |    |
| (a)     | What is Operators? List out all different types of operators. Explain Special Operator and Membership Operator with example.                                                                                                              | 03 |
| ( અ )   | ઓપરેટસGLYPH<c=25,font=/QBCAAA+Lohit-Gujarati> શું છે ?  બધા િવિવધ ,કારના ઓપરેટરોની યાદી બનાવો. GLYPH<c=8,font=/QBCAAA+Lohit-Gujarati>પેિશયલ ઓપરેટર અને મે9બરિશપ ઓપરેટર ઉદાહરણ સાથે સમGLYPH<c=28,font=/QBCAAA+Lohit-Gujarati>વો.                                      | ૦૩ |
| (b)     | Explain break, continue and pass statement with suitable example.                                                                                                                                                                         | 04 |
| ( બ )   | યો5ય ઉદાહરણ સાથે :ેક ,  કિGLYPH<c=22,font=/QBCAAA+Lohit-Gujarati>ટGLYPH<c=22,font=/QBCAAA+Lohit-Gujarati>યુ અને પાસ GLYPH<c=8,font=/QBCAAA+Lohit-Gujarati>ટ ટમેGLYPH<c=22,font=/QBCAAA+Lohit-Gujarati>ટ સમGLYPH<c=28,font=/QBCAAA+Lohit-Gujarati>વો. | ૦૪ |
| (c)     | Create a Python program to display the following patterns using loop concept.                                                                                                                                                             | 07 |
|         | 1                                                                                                                                                                                                                                         |    |
|         | 1 2                                                                                                                                                                                                                                       |    |
|         | 1 2 3                                                                                                                                                                                                                                     |    |
|         | 1 2 3 4                                                                                                                                                                                                                                   |    |
| ( ક )   | લૂપ કોGLYPH<c=22,font=/QBCAAA+Lohit-Gujarati>સે;ટનો ઉપયોગ કરીને નીચેના પેટનGLYPH<c=25,font=/QBCAAA+Lohit-Gujarati> દશાGLYPH<c=25,font=/QBCAAA+Lohit-Gujarati>વવા માટે પાયથોન ,ો-ામ બનાવો. 1                                                                    | ૦૭ |
|         | 1 2                                                                                                                                                                                                                                       |    |
|         | 1 2 3                                                                                                                                                                                                                                     |    |
|         | 1 2 3 4                                                                                                                                                                                                                                   |    |
|         | 1 2 3 4 5                                                                                                                                                                                                                                 |    |
| Q.3 (a) | Explain how to create a Set in Python by giving example.                                                                                                                                                                                  | 03 |
| ( અ )   | પાયથોનમાં સેટ કે વી રીતે બનાવવો તે ઉદાહરણ આપીને સમGLYPH<c=28,font=/QBCAAA+Lohit-Gujarati>વો.                                                                                                                                                              | ૦૩ |
| (b)     | Differentiate tuple and list.                                                                                                                                                                                                             | 04 |
| ( બ )   | Tuple  અને  list  નો તફાવત લખો                                                                                                                                                                                                                | ૦૪ |
| (c)     | Write a program that is given a dictionary containing the average daily temperature for each day of the week, and prints all the days on which the average temperature was between 40 and 50 degrees.                                     | 07 |
| ( ક )   | એક એવો ,ો-ામ લખો જેમાં અઠવાિડયાના દરેક ?દવસ માટે સરેરાશ દૈિનક તાપમાન ધરાવતી િડકશનરી આપવામાં આવે અને તે બધા ?દવસો છાપે જેમાં સરેરાશ તાપમાન  40  થી  50  િડ-ી વAચે હતું.                                                                                                                   | ૦૭ |
|         | OR                                                                                                                                                                                                                                        |    |
| (a)     | List operations of tuple (any three) and list (any three).                                                                                                                                                                                | 03 |
| ( અ )   | Tuple  અને  list  ના  operations  ની યાદી બનાવો.  ( દરેક ના કોઈપણ Bણ )                                                                                                                                                                              | ૦૩ |

|     | (b)   | Explains how to create a dictionaries in Python. Write a Python program to check if a key exists in a dictionary.                                                                                                                                                 |   04 |
|-----|-------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------|
|     | ( બ ) | પાયથોનમાં િડકશનરી કે વી રીતે બનાવવી તે સમGLYPH<c=28,font=/QBCAAA+Lohit-Gujarati>વે છે. િડકશનરીમાં કી અિGLYPH<c=8,font=/QBCAAA+Lohit-Gujarati>તCવમાં છે કે નહD તે ચકાસવા માટે પાયથોન ,ો-ામ લખો.                                                                                                       |   ૦૪ |
|     | (c)   | Write a program that counts the occurrences of each digit in a string. The  program counts how many times a digit appears in the string. For example, if the input is "12203AB3", then the output should output 0 (1 time), 1 (1 time), 2 (2 times), 3 (2 times). |   07 |
|     | ( ક ) | String માં દરેક અંકના  occurrence ની ગણતરી કરતો ,ો-ામ લખો. ,ો-ામ ગણતરી કરે છે કે િGLYPH<c=8,font=/QBCAAA+Lohit-Gujarati>ટEંગમાં અંક કે ટલી વાર દેખાય છે. ઉદાહરણ તરીકે ,  F ઇનપુટ  "12203AB3"  હોય ,  તો આઉટપુટ  0 (1  વખત ), 1 (1  વખત ), 2 (2  વખત ), 3 (2  વખત )  આઉટપુટ હોવું Fઈએ.                    |   ૦૭ |
| Q.4 | (a)   | List any six built-in functions of Python                                                                                                                                                                                                                         |   03 |
|     | ( અ ) | પાયથોનના કોઈપણ છ �બHટ - ઇન ફં IશGLYPH<c=22,font=/QBCAAA+Lohit-Gujarati>સની યાદી બનાવો.                                                                                                                                                                                      |   ૦૩ |
|     | (b)   | Define Recursion and demonstrate its working in Python with a suitable example.                                                                                                                                                                                   |   04 |
|     | ( બ ) | ?રકઝGLYPH<c=25,font=/QBCAAA+Lohit-Gujarati>નને JયાKયાિયત કરો અને યો5ય ઉદાહરણ સાથે પાયથોનમાં તેનું કાયGLYPH<c=25,font=/QBCAAA+Lohit-Gujarati> દશાGLYPH<c=25,font=/QBCAAA+Lohit-Gujarati>વો.                                                                                            |   ૦૪ |
|     | (c)   | Write a Python program to read a text file and calculate the average word length in that file                                                                                                                                                                     |   07 |
|     | ( ક ) | ટે IGLYPH<c=8,font=/QBCAAA+Lohit-Gujarati>ટ ફાઇલ વાંચવા માટે પાયથોન ,ો-ામ લખો અને તે ફાઇલમાં સરેરાશ  (average)  શLદ લંબાઈની ગણતરી કરો.                                                                                                                                                    |   ૦૭ |
|     | (a)   | Describe any three string functions with example.                                                                                                                                                                                                                 |   03 |
|     | ( અ ) | ઉદાહરણ સાથે કોઈપણ Bણ િGLYPH<c=8,font=/QBCAAA+Lohit-Gujarati>ટ Eંગ ફં Iશનનું વણGLYPH<c=25,font=/QBCAAA+Lohit-Gujarati>ન કરો.                                                                                                                                                 |   ૦૩ |
|     | (b)   | Explain the difference between the read() and readlines() functions in Python for file handling with suitable examples.                                                                                                                                           |   04 |
|     | ( બ ) | પાયથોનમાં ફાઇલ હે GLYPH<c=22,font=/QBCAAA+Lohit-Gujarati>ડGLYPH<c=7,font=/QBCAAA+Lohit-Gujarati>લગ માટે  read()  અને  readlines()  ફં Iશન વAચેનો તફાવત સમGLYPH<c=28,font=/QBCAAA+Lohit-Gujarati>વો , અને યો5ય ઉદાહરણો સાથે સમGLYPH<c=28,font=/QBCAAA+Lohit-Gujarati>વો.                |   ૦૪ |
|     | (c)   | Write a Python program to check whether a given string is a palindrome or not. Use a user-defined function and read the string from a file.                                                                                                                       |   07 |
|     | ( ક ) | આપેલ િGLYPH<c=8,font=/QBCAAA+Lohit-Gujarati>ટ Eંગ પેિલGLYPH<c=22,font=/QBCAAA+Lohit-Gujarati>ડ Eોમ છે કે નહD તે ચકાસવા માટે પાયથોન ,ો-ામ લખો.  User-defined ફં Iશનનો ઉપયોગ કરો અને ફાઇલમાંથી િGLYPH<c=8,font=/QBCAAA+Lohit-Gujarati>ટ Eંગ વાંચો.                                                  |   ૦૭ |
| Q.5 | (a)   | What is a Python module? Explain how you can import a specific function from a module with an example.                                                                                                                                                            |   03 |
|     | ( અ ) | પાયથોન મોMુલ શું છે ?  ઉદાહરણ સાથે મોMુલમાંથી  specific  ફં Iશન કે વી રીતે  import  કરી શકાય તે સમGLYPH<c=28,font=/QBCAAA+Lohit-Gujarati>વો.                                                                                                                                              |   ૦૩ |
|     | (b)   | Explain the functions plot() and show() from the Matplotlib package. Illustrate your explanation with an example of a simple line plot.                                                                                                                           |   04 |
|     | ( બ ) | Matplotlib  પેકે જમાંથી  plot()  અને  show()  ફં Iશન સમGLYPH<c=28,font=/QBCAAA+Lohit-Gujarati>વો. એક  simple line plot ના ઉદાહરણ સાથે તમારી સમજૂતી સમGLYPH<c=28,font=/QBCAAA+Lohit-Gujarati>વો.                                                                                    |   ૦૪ |

ે

ે

| (c)   | Write a Python program using the Numpy package to create a 2D array and perform array slicing to extract specific rows and columns. Then, calculate the sum and mean of the entire array.                                                                                                                                | 07   |
|-------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------|
|       | OR                                                                                                                                                                                                                                                                                                                       |      |
| (a)   | Explain the function of xlabel() and ylabel() in the Matplotlib package with a simple example.                                                                                                                                                                                                                           | 03   |
| ( અ ) | Matplotlib  પેકે જમાં  xlabel()  અને  ylabel()  નું કાયGLYPH<c=25,font=/QBCAAA+Lohit-Gujarati> એક સરળ ઉદાહરણ સાથે સમGLYPH<c=28,font=/QBCAAA+Lohit-Gujarati>વો.                                                                                                                                                                       | ૦૩   |
| (b)   | What is indexing in Numpy arrays? Demonstrate array slicing and indexing with an example using a 1D Numpy array.                                                                                                                                                                                                         | 04   |
| ( બ ) | Numpy  એરેમાં ઇGLYPH<c=22,font=/QBCAAA+Lohit-Gujarati>ડ GLYPH<c=7,font=/QBCAAA+Lohit-Gujarati>Iસગ શું છે ? 1D  ન9પી એરેનો ઉપયોગ કરીને ઉદાહરણ સાથે એરે GLYPH<c=8,font=/QBCAAA+Lohit-Gujarati>લાઇ￸સગ અને ઇGLYPH<c=22,font=/QBCAAA+Lohit-Gujarati>ડ GLYPH<c=7,font=/QBCAAA+Lohit-Gujarati>Iસગનું ,દશGLYPH<c=25,font=/QBCAAA+Lohit-Gujarati>ન કરો | ૦૪   |
| (c)   | Create a user defined module with simple functions for: addition, subtraction, multiplication, division, modulo, square, factorial. Write a program to import the module and access functions defined in the module.                                                                                                     | 07   |
| ( ક ) | સરવાળા ,  બાદબાકી ,  ગુણાકાર ,  ભાગાકાર ,  મોMુલો , square,  ફે Iટો?રયલ જેવા સરળ કાયS સાથે  user  Tારા િનધાGLYPH<c=25,font=/QBCAAA+Lohit-Gujarati>?રત મોMુલ બનાવો. મોMુલને  import  કરવા અને મોMુલમાં િનધાGLYPH<c=25,font=/QBCAAA+Lohit-Gujarati>?રત કાયSને ઍIસેસ કરવા માટે એક ,ો-ામ લખો.                                                                                 | ૦૭   |