0% found this document useful (0 votes)
14 views8 pages

Factorial Function in Python

Uploaded by

A random girl
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 (0 votes)
14 views8 pages

Factorial Function in Python

Uploaded by

A random girl
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

Unit -1

[Link] is python ?what are the Uses of python ?


[Link] Variables.
[Link] is Function?
4. Write a python program to find the length of the given
string.
[Link] out the Advantages of In-Build functions
[Link] a python program to find the given character present
or not.
[Link] is Recursion? And write any two applications.
[Link] is error detection?
[Link] out the uses of functions.
[Link] Expressions.
[Link] a python program to find the sum of the digits of a
number.
[Link] a Python program to Find the size of a Tuple.
(Big Questions)
1. Write a python function to calculate the factorial of a
number(a non-negative integer).the functions accepts the
number as an arguments
2. Write a python function to calculate the Fibonacci series.
3. How do you solve the problem of Tower of Hanoi
4. Write a Recursive function that accepts a number as its
argument and returns the sum of digits.
5. Write any five in-build function in string with example.
6. How do you reverse a message in python?
7. How do you find the length of a string without using
any-build in function?

Unit-2
1. Write short note on Boolean data type
2. List out the types of modules
3. Define class
4. Define Nested if statement.
5. What is methods?
6. Define Build-in modules
7. What are uses of user defind modules?
8. Define object oriented way.
9. Define Boolean expression Evalution
[Link] is constructor?
[Link] a Python program to Find Sum of tuple elements
[Link] while loop and for loop.
13. Write a python program to find area of a circle.
14. What is a pass in Python?
(Big Questions)
1. Write a python program to check if a year is leap year or
Not by using (Nested if)
2. Write a python program to find the maximum of three
numbers by using (Nested if)
3. Write a python program to remembering the results
Boolean Expression Evalution.
4. Write a python program calling methods the Object-
Oriented Way and Write any two examples
5. Write short note on modules.
i)Build-in modules.(math,date&time)
ii)User -defind modules(any 2 examples)
[Link] details about constructor and write any two
examples.
[Link] method and function.
[Link] a program to Check if a Number is Prime or not
9. Differentiate between List and Tuple?
10. An e-commerce company plans to give their customers a
discount
for the New Years holiday. The discount will be calculated on
the basis of the bill amount of the order placed. The discount
amount is the sum of all the odd digits ion the customer’s total
bill amount. If no odd digit is present in the bill amount, then
the discount will be [Link] an algorithm to find the
discount for the given total bill amount.
Input
The input consists of an integer bill Amount, representing the
customer’s total bill amount.
Output
Print an integer representing the discount for the given total
bill
Amount
Input:
2514795
Output
27

Unit-3
1. What is looping ?Given Example.
2. Brief the advantages of list
3. What will be the output of the following python code?
i=1
while True:
if i%3 == 0:
break
print(i)
i+=1
4. What will be the ouput of the following python code
for i in range[1,2,3,4][::-1]:
print(i,end= “ ” )
[Link] Nested looping.
[Link] a Python program to Find Sum of tuple elements
7. What is a pass in Python?
8. Write a program to find the middle element in the
dictionary.
(Big Questions)
1. ).Given a list of Numbers analyze both of the searching
Linear and binary search.
2. Write a python program to sort a list of integers in
Ascending order using selection sort algorithm.
Input:
[11,9,5,6,1]
Output:
[1,5,6,9,11]
3. Write a python program to find the second largest and
Second smallest elements in the list
[Link] a python program to find sum of all elements in list.
[Link] a python Program to Swap Two Elements in a List.
Input : List = [23, 65, 19, 90], pos1 = 1, pos2 = 3
Output : [19, 65, 23, 90]

[Link] a python program to find the second largest and


Second smallest elements in set without using predefined
function.
[Link] code to verify every odd index in a list contains odd
number and Even Index contains Even number.
Sample Input:
21436763
Sample Output:
True
8. Write a python program to search for a given pattern
INPUT:
Mumbai Tamilnadu Erode Chennai Coimbatore
tamil
OUTPUT:
Tamilnadu
UNIT 4
1. What is file handling in Python?
2. Explain the different modes of opening a file in Python.
3. How do you create a text file using Python?
4. How do you read and write to an existing file in Python?
5. Is it possible to open multiple files using Python? If yes,
how?
6. How should you handle exceptions when dealing with
files in Python?
7. What Is the Difference Between == and is?
(Big Questions)
[Link] use of Dictionaries in python program.
[Link] script to work like a SQL SELECT statement for
internal data structure made in earlier exercise.
[Link] script to work like a SQL inner join for an internal
data structure made in earlier exercise.
[Link] collections in python.

UNIT 5

1. What are the different Return Types Used by Controller


Action Methods in MVC?
2. Assembly Where the MVC Framework Is Typically
Defined:
3. What is OOP, and why is it important
4. Explain the concepts of classes and objects in Python.
5. What design patterns do you typically use when building
desktop GUI applications?
6. How are events handled in Tkinter?
7. What are the advantages of using Tkinter?

(Big Questions)

1. Explain Model, View, and Controller


2. Demonstrate Exceptions in python.
3. What are Widgets in Tkinter? Give an Example to
creating a simple button in Tkinter.
4. Write short note on Building a Basic GUI,models,views.
5. Write a python to fill the employee details of BPS
company in a database read the employee details by
creating a employee class and object.

Common questions

Powered by AI

Built-in functions in Python offer several advantages including increased programming efficiency and reduced code complexity. They provide pre-optimized solutions which save time and ensure reliability. For example, built-in functions like len(), sum(), and print() are optimized for performance and reduce the effort needed to write equivalent logic manually . Furthermore, built-in functions are well-tested and maintain consistency across different applications .

Python provides built-in support for file management with functions like open() to perform file operations. Files can be opened in various modes: 'r' for reading, 'w' for writing (with truncation), 'a' for appending, 'b' for binary mode, and 'x' to create a new file. These modes enable developers to read from, write to, or append data to files, allowing for flexible and efficient file handling in different contexts .

The primary difference between 'for' and 'while' loops in Python lies in their usage. 'For' loops are used when the number of iterations is known beforehand, typically iterating over a range, list, or iterable object. 'While' loops are used when the number of iterations is not predetermined and depends on a condition, making them suitable for situations where the loop should execute until a certain condition is false. This distinction helps developers choose the correct loop based on the predictability of iteration count .

Error detection enhances the reliability of Python programs by identifying and resolving potential errors that might cause a program to crash or produce incorrect results. Common strategies include using try-except blocks to catch and handle exceptions, validations to check input data types and values, and assertions to verify assumptions within the code. These strategies help maintain operational continuity and improve user experience by ensuring the program behaves as expected under various conditions .

Recursion in programming refers to a function calling itself to solve smaller or simpler instances of the same problem. This concept is effective in problems that naturally fit a recursive description, such as mathematical computations and problem-solving tasks. Two practical examples include calculating the factorial of a number, where the factorial function calls itself with decremented values until it reaches the base case of one, and the Fibonacci sequence, where the function calculates the sequence by summing the previous two numbers recursively .

Built-in modules are pre-installed libraries in Python offering standard functionality, like math and datetime, which are efficient and thoroughly tested. User-defined modules are custom-written by developers to encapsulate specific functions and data relevant to particular applications. They are preferred in situations requiring specialized functionality not covered by built-in modules, allowing for improved organization and reusability of code across different programs .

Lists and tuples are both sequence data types but they differ mainly in mutability. Lists are mutable, allowing for element addition, deletion, or modification, making them suitable for collections of items that may change over time. Tuples, however, are immutable, so they are ideal for fixed collections of items that should not change, such as coordinate pairs in geometric computations. Additionally, tuples typically have faster access times due to their immutability .

Recursion allows a function to call itself to solve smaller instances of the same problem, which simplifies the code for inherently recursive problems like factorial calculation and the Fibonacci sequence. Two applications of recursion include the Tower of Hanoi problem, which involves moving disks between rods while adhering to specific rules, and the generation of all permutations of a set, crucial in problems related to combinatorics .

Object-Oriented Programming (OOP) in Python provides several benefits, including code reusability through inheritance, data encapsulation which protects data integrity, and ease of maintenance by organizing code into logical classes and objects. This paradigm is important because it mirrors real-world entities, thus improving the understanding and design of complex software projects. OOP principles also enhance data modeling capabilities and enable polymorphism which allows methods to be defined in a superclass and overwritten by subclasses for flexibility .

Exception handling in file operations is crucial for preventing runtime errors related to file access, ensuring program reliability. Strategies include using try-except-finally blocks to manage errors, such as FileNotFoundError or IOError, without crashing the program. Implementing finally blocks ensures that files are properly closed after operations. Using 'with' statements also handles file operations cleanly by automatically managing resource cleanup even in case of exceptions, enhancing code readability and robustness .

You might also like