JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY HYDERABAD
JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY HYDERABAD B.Tech II PYTHON PROGRAMMING Previous Question Paper (August/ September - 2022 - R18)
Answer any five questions
All questions carry equal marks
Main
Discuss about various kinds of List Access Methods in Python.
Answer
List access methods in Python allow for retrieving, modifying, or traversing elements within a list. The primary methods include:
- Indexing: Accessing a single element using its position. Python uses zero-based indexing, where the first element is at index 0. Negative indexing allows access from the end of the list, where -1 refers to the last element.
- Slicing: Extracting a sub-list using the syntax list[start:stop:step]. This creates a new list containing elements from the start index up to, but not including, the stop index, with an optional step value.
- Iteration: Traversing the list using loops. The for loop is the most common way to access each element sequentially. Alternatively, enumerate() can be used to access both the index and the value simultaneously.
- Membership Testing: Using the in operator to check if a specific element exists within the list, returning a boolean value.
- List Methods for Access/Search: Methods like index() return the position of the first occurrence of a value, and count() returns the number of times a value appears in the list.
Write a python program to find factorial of a given number using functions.
Answer
To calculate the factorial of a number using a function, one can use either an iterative approach or a recursive approach. Below is the iterative implementation:
def factorial(n):
if n < 0:
return "Factorial does not exist for negative numbers"
result = 1
for i in range(1, n + 1):
result *= i
return result
num = int(input("Enter a number: "))
print(f"The factorial of {num} is {factorial(num)}")List out any five string built-in functions in python.
Answer
Sign in to view the complete answer paper.
Write a python script for finding given string is palindrome or not.
Answer
Sign in to view the complete answer paper.
How to manipulate directories in python? Explain with suitable examples.
Answer
Sign in to view the complete answer paper.
Illustrate Math module in python.
Answer
Sign in to view the complete answer paper.
Write a program to illustrate “file not found” exception.
Answer
Sign in to view the complete answer paper.
How to import a module to the python script? Give example.
Answer
Sign in to view the complete answer paper.
How to create a thread? Illustrate with an example.
Answer
Sign in to view the complete answer paper.
Discuss about thread life cycle.
Answer
Sign in to view the complete answer paper.
Explain the special characters in python.
Answer
Sign in to view the complete answer paper.
Explain about thread module.
Answer
Sign in to view the complete answer paper.
How to define a canvas? Write a program to draw a bar chart on a Canvas.
Answer
Sign in to view the complete answer paper.
Write in brief about web surfing in Python.
Answer
Sign in to view the complete answer paper.
Write a python script to create a table, delete and display the data from database.
Answer
Sign in to view the complete answer paper.
Write a python script for database connectivity with an example.
Answer
Sign in to view the complete answer paper.