0% found this document useful (1 vote)
819 views2 pages

Python Lab Exam Questions 2021

This document contains 9 sets of questions for a Python lab exam for an MCA program. Each question set contains 2 programming questions and is assigned to a range of student roll numbers. The questions cover a variety of Python programming concepts like string manipulation, lists, tuples, searching, sorting, mathematical operations, and more. The exam will take place on May 20th, 2021 from 9:30-10:30 AM.

Uploaded by

Komal Singh
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
819 views2 pages

Python Lab Exam Questions 2021

This document contains 9 sets of questions for a Python lab exam for an MCA program. Each question set contains 2 programming questions and is assigned to a range of student roll numbers. The questions cover a variety of Python programming concepts like string manipulation, lists, tuples, searching, sorting, mathematical operations, and more. The exam will take place on May 20th, 2021 from 9:30-10:30 AM.

Uploaded by

Komal Singh
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
  • Exam Instructions and Question Sets

BHILAI INSTITUTE OF TECHNOLOGY

::MCA – Autonomous, Exam Nov-Dec 2020::


Subject:Python Lab.
Subject Code : 261193CA Branch : M.C.A. Semester : First
Time : 9:30am- 10:30 am (Writing work) – 1 Hr Date : 20.05.2021 (Thursay)

Question set #1 (Class Rno 1 to 5)


1. Write a Python program to print the sum of digits and reverse of the number.
2. Write a Python program to count number of consonants in a sentence.

Question set #2 (Class Rno 6 to 10)


3. Write a Python program to find whether a number is a prime or not.
4. Write a Python program to Insertion ,deletion in list.

Question set #3 (Class Rno 11 to 20)


5. Write a Python program to print check whether a number is palindrome or not?
6. Write a Python program to create a list and find Sum of elements of that list.

Question set #4 (Class Rno 21to 25)


7. Write a Python program to check whether a number is an Armstrong number or not.
8. Write a Python program to create a tuple and find Sum of elements of that tuple.

Question set #5 (Class Rno 26 to 30)


9. Write a Python program to sort elements of a list.
10. Write a Python program to input two strings and concatenate them.

Question set #6 (Class Rno 31 to 35)


11. Write a Python program to search an integer in a list of integers using Linear Search.
12. Write a Python program to input principal amount, rate of interest and time and calculate simple interest.

Question set #7 (Class Rno 36 to 40)


13. Write a Python program to create a tuple and to find Greatest and Smallest element of tuple.
14. Write a Python program to greatest of 5 numbers.
Question set #8 (Class Rno 41 to 45)
15. Write a Python program to find factorial of a number.
16. Write a Python program to find compound interest

Question set #9 (Class Rno 46 to 48)


17. Write a Python program to find Greatest and Smallest element of list.
18. Write a Python program to count number of vowels in a sentence.

Common questions

Powered by AI

Python lists are well-suited for insertion and deletion because they provide native methods (`insert()`, `pop()`, and `remove()`) that facilitate these operations. However, efficiency can be a concern for large lists due to the O(n) complexity for operations that resize the list, such as insertions and deletions not near list ends. In contrast, Python's `collections.deque` offers more efficient O(1) operations for additions and removals from both ends of a sequence.

While simple interest calculation follows a direct formula involving principal, rate, and time, which can be computed in one step, compound interest, especially with compounding periods, typically requires iteratively or recursively applying interest over each period to the principal. This compounded amount becomes the new principal for subsequent periods, thus involving a looped or recursive approach for accurate computation.

Finding the greatest of five numbers involves comparing each number with a current maximum being tracked. This requires a fixed number of comparisons (five comparisons in the worst case), making it a simple application of direct comparison logic. It scales linearly with the number of elements, as each added element increases the number of comparisons by one, maintaining an O(n) time complexity.

Checking for an Armstrong number involves calculating the power of its digits (raised to the number of digits) and summing them, then comparing this sum to the original number. This process requires multiple exponentiation operations and digit extractions, which are more computationally intensive than palindromes, which merely involve reversing digits and comparing, leading to increased computational complexity in the former.

Concatenating strings in Python uses the '+' operator, which, unlike numerical operations, does not perform mathematical addition but rather joins the strings end-to-end to form a new string. This operation is computational in string handling and does not result in any arithmetic sum, differentiating it significantly from arithmetic operations where '+' operates mathematically.

The benefits of using Python lists for linear search include ease of implementation and direct access to elements via indices. However, a demerit includes suboptimal efficiency for large data sets due to O(n) time complexity, making it less suitable for performance-critical applications compared to more efficient data structures or search algorithms such as binary search on sorted data, which performs better with O(log n) complexity.

A linear search on a list has a time complexity of O(n) because it involves traversing the list once to find the target integer. In contrast, sorting a list has higher time complexity; typical sorting algorithms like Merge Sort have a time complexity of O(n log n). Hence, linear search is generally more computationally efficient for single searches compared to complete sorting, which rearranges the entire list even if only a single element needs to be located.

Optimizing search for greatest and smallest elements involves reducing unnecessary comparisons. A common optimization is using a single pass through the list or tuple to update both greatest and smallest values, reducing the number of traversals to one. However, since tuples are immutable, the process doesn’t affect them differently than lists, aside from access operations. Efficient algorithms may employ early termination or parallel processing for large datasets to further optimize.

Conceptually, both programs involve repetitive processes: checking each condition (characters) in the case of palindromes and iterative multiplication in factorials. The practical difference lies in the nature of these processes; palindrome checks involve symmetric comparison, while factorial calculations require iterative or recursive numerical multiplications, thus necessitating different logic implementations and operation complexity.

Finding the sum of elements in a Python list or a tuple involves similar logic, wherein you iterate over the elements and increment a cumulative sum variable. However, the primary difference lies in the data structure's mutability; lists are mutable, allowing elements to be modified, added, or removed, whereas tuples are immutable. Therefore, the process of summing elements in a tuple must handle immutability without altering the tuple itself.

BHILAI INSTITUTE OF TECHNOLOGY
::MCA – Autonomous, Exam Nov-Dec 2020::
Subject:Python  Lab.
Subject Code : 261193CA
Branch :
Question
 
   set
    #8 (Class
 
    Rno 41 to 45)
 
 
15. Write a Python program to find factorial of a number.
16. Write a

You might also like