Python Question BAnk

Python Question BAnk :

 

Basic Python Questions

  1. What is Python?
    → Explain what Python is and why it is popular.

  2. What are variables in Python?
    → Define variables and show how to assign values.

  3. What are data types in Python?
    → List examples: int, float, str, bool, list, etc.

  4. What is the difference between mutable and immutable objects?
    → Example: list is mutable, tuple and string are immutable.

  5. What are Python keywords?
    → Define and give examples like if, for, while, def, class.

  6. What is the difference between is and == operators?
    is checks identity, == checks equality of values.

  7. What are lists and tuples in Python?
    → Explain both with examples and key differences.

  8. What is a function in Python?
    → Explain and show how to define one using def.

  9. What is indentation in Python and why is it important?
    → Explain how it defines code blocks instead of braces {}.

  10. What are conditional statements in Python?
    → Explain if, elif, and else with a small example.

 

 

Part 2: 

 

Explain for and While loops with appropriate example in python.

Write a program that takes user marks obtained in 5 subjects as input and print their grade based on criteria (A,B,C,D)

The grade will be calculated according to the average score of subjects:

1.score >=90 :A

2.score >=80 :B

3.score >=70 :C

4.score >=60 :D

 

i)Write a program to check an input number is prime or not.

ii)Design a basic calculator in Python that support addition, subtraction, multiplication and division

(i)  What are operators? Explain conditional and logical operators with the help of example.

(ii)  What will be the output of the following python code:

>> result = 10 + 3 * 2 ** 2 - (5 / 2 + 6) // 1 >> print(result)

 

Explain each lists manipulation method given below  with a  suitable example

append ( )  ,extend(), pop( ), remove(), len(),max() ,clear( )

 

Explain the difference between is and == operator.

In some languages, every statement ends with semi-colon (;). What happens if you put a semi-colon at the end of python statement?

What are Python’s data types?

What will be the output of the following python code

def count1(s):

    vowels = "AEIOUaeiou"

    count = 0

    for c in s:

        if c in vowels:

            count +=1

    return count

print(count1("I am learning python")).

 

What are Python’s built-in data structures?

How are break, continue, and pass used in loops? Support your answers with example.

 

 

 

 

 

 

1)Write a program to swap two numbers without using any temporary variable.

2)How to create a dictionary . Explain with the help of an example

What is the difference between local and global variables in Python. Explain with suitable example.

 

Illustrate different list slicing constructs for the following operations on the

following list:   L = [1,2, 3, 4, 5, 6, 7, 8, 9]

1.Return a list of numbers starting from the last to second item of the list

2.Return a list that start from 3rd item to second last item.

3.Return a list that has only even position elements of list L to list M.

4.Return a list that starts from the middle of the list L.

What is the difference between mutable and immutable objects?

Leave Comment

Important Topics

Title
Python Program AKTU 2022 Question Paper
Python Question BAnk