Enrollment No./Seat No.:

## GUJARAT TECHNOLOGICAL UNIVERSITY DIPLOMA IN ENGINEERING - SEMESTER - II EXAMINATION WINTER 2025

Subject Code: DI02000101

Date: 20-01-2026

Subject

Name:

Scripting Language

Time: 10:30 AM TO 01:00PM

Total Marks: 70

Instructions:

## 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.

5. English version is authentic.

|         |                                                                                                                          | Marks   |
|---------|--------------------------------------------------------------------------------------------------------------------------|---------|
| Q.1 (a) | List any six python operators.                                                                                           | 03      |
| ( અ )   | કોઈપણ છ   python operators  ની યાદી લખો .                                                                                     | ૦૩      |
| (b)     | Describe datatypes of python.                                                                                            | 04      |
| ( બ )   | Python  ના   datatypes   ન ું વણણન કરો .                                                                                     | ૦૪      |
| (c)     | Write a python program to calculate simple and compound interest.                                                        | 07      |
|         | Simple Interest =   P∗R∗T 100                                                                                            |         |
|         | Compound Interest =  P  ∗ (1+ R 100∗n ) n∗T                                                                              |         |
| ( ક )   | Simple  અને  compound interest   શોધવા નો  python   પ્રોગ્રામ લખો .                                                               | ૦૭      |
|         | Simple Interest  =   P∗R∗T 100                                                                                           |         |
|         | compound Interest  =  P  ∗ (1+ R 100∗n ) n∗T                                                                             |         |
|         | OR                                                                                                                       |         |
| (c)     | 1) Write a python program to convert temperature from Celsius to  Fahrenheit. Equation to convert Celsius to Fahrenheit: | 07      |

<!-- formula-not-decoded -->

|     |       | 2) Write a python program to compute the slope of a line between two  points (x1, y1) and (x2, y2).                                                        |    |
|-----|-------|------------------------------------------------------------------------------------------------------------------------------------------------------------|----|
|     |       | Slope =  𝑦2-𝑦1 𝑥2-𝑥1                                                                                                                                       |    |
|     | ( ક ) | 1)  આપેલ   Celsius  temperature  ને   to Fahrenheit  માું  convert  કરવા માટેનો python  પ્રોગ્રામ લખો .                                                                  | ૦૭ |
|     |       | F = (9/5)  ∗  C + 32.                                                                                                                                      |    |
|     |       | 2)  આપેલ બે પોઈન્ટ  (x1, y1)  અને  (x2, y2)  વચ્ચે નો  slope  શોધવાનો   python  પ્રોગ્રામ લખો .                                                                            |    |
|     |       | Slope =  𝑦2-𝑦1 𝑥2-𝑥1                                                                                                                                       |    |
| Q.2 | (a)   | State the use of break, pass and continue statement.                                                                                                       | 03 |
|     | ( અ ) | Break, pass  અને  continue statement  નો ઉપયોગ લખો .                                                                                                           | ૦૩ |
|     | (b)   | Describe for loop with an example.                                                                                                                         | 04 |
|     | ( બ ) | For  લૂપ ને ઉદાહરણ સાથે સમજાવો .                                                                                                                                  | ૦૪ |
|     | (c)   | Write a python program to read the marks and assign a grade to a student.  Grading system: A (>=90), B (80-89), C (70-79), D (60-69), E (50-59), F  (<50). | 07 |
|     | ( ક ) | User  પાસેથી માકણસ એન્ટર કરાવી અને સ્ટ  ડન્ટ ને ગ્રેડ  assign  કરવાનો  python  પ્રોગ્રામ લખો .                                                                                 | ૦૭ |
|     |       | Grading system: A (>=90), B (80-89),C (70-79), D (60-69), E (50-59), F  (<50)                                                                              |    |
|     |       | OR                                                                                                                                                         |    |
|     | (a)   | State the use of range() function with its syntax and example.                                                                                             | 03 |
|     | ( અ ) | Range()  ફું ક્શનનો ઉપયોગ તેના  syntax  અને ઉદાહરણ સાથે લખો .                                                                                                          | ૦૩ |
|     | (b)   | Describe while loop with an example.                                                                                                                       | 04 |
|     | ( બ ) | While  લૂપ ને ઉદાહરણ સાથે સમજાવો .                                                                                                                                | ૦૪ |
|     | (c)   | Write a python program to read n numbers from users and calculate the  average of those n numbers.                                                         | 07 |
|     | ( ક ) | User  પાસેથી  n  નુંબર એન્ટર કરાવી અને તે   n  numbers   ની average   શોધવાનો  python  પ્રોગ્રામ લખો .                                                                        | ૦૭ |
| Q.3 | (a)   | Define following terms: List, tuple and dictionary.                                                                                                        | 03 |
|     | ( અ ) | નીચેના શબ્દો વ્યાખ્યાયયત કરો : list, tuple, dictionary.                                                                                                              | ૦૩ |
|     | (b)   | Describe basic operations of dictionary with an example.                                                                                                   | 04 |
|     | ( બ ) | Dictionary  ના   basic operations ન ું ઉદાહરણ આપીને વણણન કરો .                                                                                                    | ૦૪ |
|     | (c)   | Write a python program to perform the below operations on the list:                                                                                        | 07 |

| ( ક )   | Create a list.  Add/Remove an item to/from a list.  Get the number of elements in the list.  Access elements of the list using the index.  Sort the list.  Reverse the list.  નીચે આપેલ  operation  યલસ્ટ પર  apply  કરતો  python  પ્રોગ્રામ લખો .   | ૦૭   |
|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------|
|         | યલસ્ટ બનાવો                                                                                                                                                                                                                                   |      |
|         | યલસ્ટ માુંથી  item add /remove  કરો                                                                                                                                                                                                              |      |
|         | યલસ્ટ ના  number of  element  યપ્રન્ટ કરો                                                                                                                                                                                                       |      |
|         | યલસ્ટ ના એયલમેંટ ને  index  થી  access  કરો                                                                                                                                                                                                       |      |
|         | યલસ્ટ ને  sort   કરો                                                                                                                                                                                                                          |      |
|         | યલસ્ટ ને  reverse  કરો .                                                                                                                                                                                                                      |      |
| (a)     | Give the difference between List and Tuple.                                                                                                                                                                                                | 03   |
| ( અ )   | List  અને  tuple  વચ્ચેનો તફાવત લખો .                                                                                                                                                                                                            | ૦૩   |
| (b)     | Describe basic operation of set with an example.                                                                                                                                                                                           | 04   |
| ( બ )   | Set  ના   basic operations ન ું ઉદાહરણ આપીને વણણન કરો .                                                                                                                                                                                           | ૦૪   |
| (c)     | Write a python  program to read n numbers from a user and print:                                                                                                                                                                           | 07   |
|         | Number of positive numbers.                                                                                                                                                                                                                |      |
|         | Number of negative numbers.                                                                                                                                                                                                                |      |
|         | Number of zeros.                                                                                                                                                                                                                           |      |
|         | Number of odd numbers.                                                                                                                                                                                                                     |      |
|         | Number of even numbers.                                                                                                                                                                                                                    |      |
|         | Average of all numbers.                                                                                                                                                                                                                    |      |
| ( ક )   | ય ઝર પાસથી  n  નુંબર રીડ કરાવી ,  નીચે આપેલ યપ્રન્ટ કરવાનો  python  પ્રોગ્રામ                                                                                                                                                                                | ૦૭   |

લખો

.

|       | number of    પોયિયટવ નુંબર                                                                                                                                                                                      |    |
|-------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----|
|       | number of    નેગેયટવ નુંબર                                                                                                                                                                                      |    |
|       | number of   zero  નુંબર                                                                                                                                                                                       |    |
|       | number of  odd  નુંબર                                                                                                                                                                                         |    |
|       | number of   even  નુંબર                                                                                                                                                                                       |    |
|       | બધા નુંબર ની  average.                                                                                                                                                                                          |    |
| (a)   | List out any three built in function with its usage.                                                                                                                                                        | 03 |
| ( અ ) | ઉપયોગ સાથે કોઈપણ ત્રણ યબલ્ટ - ઇન ફું ક્શનની યાદી બનાવો .                                                                                                                                                                  | ૦૩ |
| (b)   | Describe recursion with an example.                                                                                                                                                                         | 04 |
| ( બ ) | ઉદાહરણ સાથે  recursion ન ું વણણન કરો .                                                                                                                                                                            | ૦૪ |
| (c)   | Write  a  python  program  that  defines  a  function  to  return  a  new  list  by  eliminating the duplicate values in the list.                                                                          | 07 |
| ( ક ) | યલસ્ટ માુંથી ડ  યલલકેટ  items  ને યરમૂવ કરીને નવ ું યલસ્ટ બનાવી તેને  return  કરવાન ું ફું કશન બનાવવા નો  python  પ્રોગ્રામ લખો .                                                                                                         | ૦૭ |
|       | OR                                                                                                                                                                                                          |    |
| (a)   | List any three math library function with its usage.                                                                                                                                                        | 03 |
| ( અ ) | કોઈપણ ત્રણ  maths   લાઇબ્રેરી ફું ક્શનની ઉપયોયગતા સાથે યાદી બનાવો .                                                                                                                                                           | ૦૩ |
| (b)   | Describe function to read and write from a file.                                                                                                                                                            | 04 |
| ( બ ) | ફાઇલમાુંથી  read  અને  write  માટેના ફું ક્શનન ું વણણન કરો .                                                                                                                                                               | ૦૪ |
| (c)   | Write a python  program to check whether a given string is  palindrome or  not.                                                                                                                             | 07 |
| ( ક ) | આપેલ યસ્ટ રું ગ પેયલન્ડ ર ોમ છે કે નહીું તે ચકાસવા માટેનો  python  પ્રોગ્રામ લખો .                                                                                                                                                 | ૦૭ |
| (a)   | Describe numpy array with an example.                                                                                                                                                                       | 03 |
| ( અ ) | ઉદાહરણ સાથે  numpy array  ન ું વણણન કરો .                                                                                                                                                                         | ૦૩ |
| (b)   | Describe any two string  function with an example.                                                                                                                                                          | 04 |
| ( બ ) | કોઈપણ બે યસ્ટ રું ગ ફું ક્શનન ું ઉદાહરણ સાથે વણણન કરો .                                                                                                                                                                   | ૦૪ |
| (c)   | Create  a  user  defined  module  with  simple  functions  for:  addition,  subtraction, multiplication, division. Write a python program to import the  module and access functions defined in the module. | 07 |
| ( ક ) | સરવાળા ,  બાદબાકી ,  ગ ણાકાર ,  ભાગાકાર શોધવા માટેના ફું કશન યનધાણયરત મોડ્ય લ બનાવો .  તે મોડ્ય લને  import   કરવા અને મોડ્ય લમાું યનધાણયરત ફું કશન ને ઍક્સેસ કરવા માટે  python   પ્રોગ્રામ લખો .                                                          | ૦૭ |
|       | OR                                                                                                                                                                                                          |    |
| (a)   | Define module. Write names of in built module in python.                                                                                                                                                    | 03 |
| ( અ ) | મોડ્ય લ વ્યાખ્યાયયત કરો . python  માું  in built   મોડ્ય લના નામ લખો .                                                                                                                                                     | ૦૩ |

| (b)   | Describe any two  functions of the matplotlib package.                                       |   04 |
|-------|----------------------------------------------------------------------------------------------|------|
| ( બ ) | Matplotlib  પેકેિના કોઈપણ બે   functions  ન ું વણણન કરો .                                             |   ૦૪ |
| (c)   | Write a python program to create a numpy array and apply any five  operation of numpy array. |   07 |
| ( ક ) | Numpy array   બનાવવા માટે તથા  Numpy array ના કોઈપણ પાુંચ ઓપરેશન apply   કરવાનો  python  પ્રોગ્રામ લખો .       |   ૦૭ |