PYQs

Python Programming

2 papers · 100218

2025100218

B.Tech 2nd Semester Examination, 2025

03 Hours70 marks

Instructions

  • The marks are indicated in the right-hand margin.
  • There are NINE questions in this paper.
  • Attempt FIVE questions in all.
  • Question No. 1 is compulsory.

Q.1 Choose the correct option / answer the following (Any seven question only):

Ask AI
  1. Q1.1

    Which of the following is a valid variable name in Python?

    a)

    2value

    b)

    value2

    c)

    value-2

    d)

    value 2

    Ask AI
  2. Q1.2

    Which symbol is used for comments in Python?

    a)

    //

    b)

    /* */

    c)

    d)

    <!-- -->

    Ask AI
  3. Q1.3

    Which function is used to take input from the user?

    a)

    scanf()

    b)

    gets()

    c)

    read()

    d)

    input()

    Ask AI
  4. Q1.4

    Which of the following will create an empty dictionary?

    a)

    dict()

    b)

    {}

    c)

    []

    d)

    set()

    Ask AI
  5. Q1.5

    What is the correct syntax to define a function in Python?

    a)

    function fun():

    b)

    def fun():

    c)

    def fun[]:

    d)

    define fun():

    Ask AI
  6. Q1.6

    "Hello"[1] gives:

    a)

    H

    b)

    e

    c)

    l

    d)

    o

    Ask AI
  7. Q1.7

    Which method is used to find length of a string?

    a)

    length()

    b)

    size()

    c)

    count()

    d)

    len()

    Ask AI
  8. Q1.8

    Lists in Python are

    a)

    Mutable

    b)

    Immutable

    c)

    Constant

    d)

    None

    Ask AI
  9. Q1.9

    Which method removes the last element from a list?

    a)

    remove()

    b)

    pop()

    c)

    clear()

    d)

    delete()

    Ask AI
  10. Q1.10

    Which of the following is used to open a file in Python?

    a)

    file()

    b)

    open()

    c)

    read()

    d)

    fopen()

    Ask AI

Q.2 Solve both questions:

Ask AI
  1. Q2.1

    Explain Identifiers, Keywords, Statements, and Expressions in Python.

    Ask AI
  2. Q2.2

    Explore the working of while and for loop with examples.

    Ask AI

Q.3 Solve both questions:

Ask AI
  1. Q3.1

    Explain Assignment and Relational operators in python with program?

    Ask AI
  2. Q3.2

    What is type conversion? Explain with example?

    Ask AI

Q.4 Solve both questions:

Ask AI
  1. Q4.1

    Explain elseif ladder in python programming with suitable example.

    Ask AI
  2. Q4.2

    Write a Python program to count how many numbers in a given list are even and how many are odd.

    Ask AI

Q.5 Solve both questions:

Ask AI
  1. Q5.1

    Explain the scope and lifetime of variables with examples. Also demonstrate how the global keyword is used to modify global variables inside a function.

    Ask AI
  2. Q5.2

    Write a function factors (N) that returns a list of all positive divisors of N (N>=1).
    For example:
    factors (6) returns [1,2,3,6]
    factors (1) returns [1]
    factors (13) returns [1,13]

    Ask AI

Q.6 Solve both questions:

Ask AI
  1. Q6.1

    Explain concatenation, comparison, and length operation. Support your explanation with suitable example programs.

    Ask AI
  2. Q6.2

    Explain commonly used string methods such as upper(), lower(), strip(), find(), replace(), split(), join(), etc. Write example code demonstrating at least five string methods.

    Ask AI

Q.7 Solve both questions:

Ask AI
  1. Q7.1

    Explain operations such as concatenation, repetition, membership, and length in list with program?

    Ask AI
  2. Q7.2

    Explain indexing and slicing in lists with examples. Discuss: Positive and negative indexing, Accessing single elements, Slicing formats: list[start:end], list[start:end:step].

    Ask AI

Q.8 Solve both questions:

Ask AI
  1. Q8.1

    What are nested loops? Write a program to print the following pattern using nested for loops:

    *
    * *
    * * *
    * * * *

    Ask AI
  2. Q8.2

    Explain commonly used methods like add(), update(), remove(), discard(), union() in set with program?

    Ask AI

Q.9 Solve both questions:

Ask AI
  1. Q9.1

    How to perform read operation in text file explain with example?

    Ask AI
  2. Q9.2

    Write a Python function to count the frequency of each character in a given a string and return the output in a dictionary. Example: char_frequency ("HELLO") returns {'H': 1, 'E': 1, 'L': 2, 'O': 1}.

    Ask AI

2025V4100218

B.Tech 2nd Semester Examination, 2025

03 Hours70 marks

Instructions

  • The marks are indicated in the right-hand margin.
  • There are NINE questions in this paper.
  • Attempt FIVE questions in all.
  • Question No. 1 is compulsory.

Q.1 Choose the correct option / answer the following (Any seven question only):

Ask AI
  1. Q1.1

    Which of the following is a valid variable name in Python?

    a)

    2value

    b)

    value2

    c)

    value-2

    d)

    value 2

    Ask AI
  2. Q1.2

    Which symbol is used for comments in Python?

    a)

    //

    b)

    /* */

    c)

    d)

    <!-- -->

    Ask AI
  3. Q1.3

    Which function is used to take input from the user?

    a)

    scanf()

    b)

    gets()

    c)

    read()

    d)

    input()

    Ask AI
  4. Q1.4

    Which of the following will create an empty dictionary?

    a)

    dict()

    b)

    {}

    c)

    []

    d)

    set()

    Ask AI
  5. Q1.5

    What is the correct syntax to define a function in Python?

    a)

    function fun():

    b)

    def fun():

    c)

    def fun[]:

    d)

    define fun():

    Ask AI
  6. Q1.6

    "Hello"[1] gives:

    a)

    H

    b)

    e

    c)

    l

    d)

    o

    Ask AI
  7. Q1.7

    Which method is used to find length of a string?

    a)

    length()

    b)

    size()

    c)

    count()

    d)

    len()

    Ask AI
  8. Q1.8

    Lists in Python are

    a)

    Mutable

    b)

    Immutable

    c)

    Constant

    d)

    None

    Ask AI
  9. Q1.9

    Which method removes the last element from a list?

    a)

    remove()

    b)

    pop()

    c)

    clear()

    d)

    delete()

    Ask AI
  10. Q1.10

    Which of the following is used to open a file in Python?

    a)

    file()

    b)

    open()

    c)

    read()

    d)

    fopen()

    Ask AI

Q.2 Solve both questions:

Ask AI
  1. Q2.1

    Explain Identifiers, Keywords, Statements, and Expressions in Python.

    Ask AI
  2. Q2.2

    Explore the working of while and for loop with examples.

    Ask AI

Q.3 Solve both questions:

Ask AI
  1. Q3.1

    Explain Assignment and Relational operators in python with program?

    Ask AI
  2. Q3.2

    What is type conversion? Explain with example?

    Ask AI

Q.4 Solve both questions:

Ask AI
  1. Q4.1

    Explain elseif ladder in python programming with suitable example.

    Ask AI
  2. Q4.2

    Write a Python program to count how many numbers in a given list are even and how many are odd.

    Ask AI

Q.5 Solve both questions:

Ask AI
  1. Q5.1

    Explain the scope and lifetime of variables with examples. Also demonstrate how the global keyword is used to modify global variables inside a function.

    Ask AI
  2. Q5.2

    Write a function factors (N) that returns a list of all positive divisors of N (N>=1).
    For example:
    factors (6) returns [1,2,3,6]
    factors (1) returns [1]
    factors (13) returns [1,13]

    Ask AI

Q.6 Solve both questions:

Ask AI
  1. Q6.1

    Explain concatenation, comparison, and length operation. Support your explanation with suitable example programs.

    Ask AI
  2. Q6.2

    Explain commonly used string methods such as upper(), lower(), strip(), find(), replace(), split(), join(), etc. Write example code demonstrating at least five string methods.

    Ask AI

Q.7 Solve both questions:

Ask AI
  1. Q7.1

    Explain operations such as concatenation, repetition, membership, and length in list with program?

    Ask AI
  2. Q7.2

    Explain indexing and slicing in lists with examples. Discuss: Positive and negative indexing, Accessing single elements, Slicing formats: list[start:end], list[start:end:step].

    Ask AI

Q.8 Solve both questions:

Ask AI
  1. Q8.1

    What are nested loops? Write a program to print the following pattern using nested for loops:

    *
    * *
    * * *
    * * * *

    Ask AI
  2. Q8.2

    Explain commonly used methods like add(), update(), remove(), discard(), union() in set with program?

    Ask AI

Q.9 Solve both questions:

Ask AI
  1. Q9.1

    How to perform read operation in text file explain with example?

    Ask AI
  2. Q9.2

    Write a Python function to count the frequency of each character in a given a string and return the output in a dictionary. Example: char_frequency ("HELLO") returns {'H': 1, 'E': 1, 'L': 2, 'O': 1}.

    Ask AI

Support BEUConnect

Contributions cover the domain and hosting.

UPI QR code for pritkr@cnrb
pritkr@cnrb

Add to home screen

  1. Tap Share in Safari.
  2. Choose Add to Home Screen.