0% found this document useful (0 votes)
3 views28 pages

Python

The document contains a series of Python programming practicals and viva questions designed for learning Python. It includes tasks such as finding sums, checking even/odd numbers, and working with lists and dictionaries. Additionally, it features questions about Python's syntax, data types, and functions to test understanding of the language.

Uploaded by

ritikjanghu02080
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)
3 views28 pages

Python

The document contains a series of Python programming practicals and viva questions designed for learning Python. It includes tasks such as finding sums, checking even/odd numbers, and working with lists and dictionaries. Additionally, it features questions about Python's syntax, data types, and functions to test understanding of the language.

Uploaded by

ritikjanghu02080
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

PYTHON PROGRAMMES

Karan Chahal (25bcom041)

Practical 1: Write a programme to find sum


of 2 numbers
Practical 2: Write a programme find sum of
two complex numbers
Practical 3: Write a programme to
concatenate 2 strings
Practical 4: Write a programme calculating
perimeter of rectangle
Practical 5: write a program to swape 2
number using and without using 3 variables.
Practical 6: without using 3 variables
Practical 7: write a program for Sum of digits
of a three-digit number.
Practical 8: write a program to check
whether a number is even or odd.
Practical 9: write a program to find largest of
2 number.
Practical 10: write a program to find largest
of 3 numbers if Elif else ladder.
Practical 11: write a program to find largest
of 4 numbers.
Practical 12: write a program to find roots of a
quadratic equation.
Practical13: write a program to find factorial of a
number.
Practical14: write a program to find
Practical15: write a program to find table of a
number
Practical16: write a program to check weather a
number is prime or not.
Practical17: write a program to find a^b

Function
Practical18: write a program to find sum of 3
numbers
Programme19: write a program to find area and
perimeter of triangle using function
Programme20: write a program to stimulate in
python
Practical 21: WAP to find sum of no. using
sum function
Practical 22: Write a programme find sum of no.
using sum function
Practical 23: WAP to swap first and last
element of list using loops

Practical 24: WAP to sum of all elements in


dictionary
Practical 25: WAP to get max and min
value in a dictionary
VIVA QUESTIONS (PYTHON)
No. Question Answer

1 Who developed Python? Guido van Rossum

2 Is Python case-sensitive? Yes

3 What is the extension of a Python file? .py

4 Which keyword is used to create a function? def

5 Are strings in Python mutable or immutable? Immutable

6 Which data type stores a sequence of key-value pairs? Dictionary

7 Which function is used to take input from the user? input ()

8 What is the output of type (3.14)? float

9 Which operator is used for floor division? //

10 Which keyword is used for a loop that has a fixed range? for

11 Which symbol is used for comments in Python? #

12 Is indentation mandatory in Python? Yes

13 Which function gives the length of a list? Len ()

14 Can a tuple be changed after creation? No

15 What is the output of bool (0)? False

16 Which keyword is used to handle exceptions? try

17 Which operator is used for "to the power of"? **

19 Which method adds an element at the end of a list? append ()


No. Question Answer

20 Which data type is used to store unique elements? Set

21 Which keyword is used to import a module? import

What is the default


22 18 return value of a
function?

23 Which keyword is used to skip the current iteration? continue

24 Which keyword exits a loop entirely? break

25 What is a variable defined outside any function called? Global

26 Which method converts a string to lowercase? lower ()

27 Which block is always executed in exception handling? finally,

28 Is Python an interpreted or compiled language? Interpreted

29 Which function opens a file in Python? open ()

30 What is the index of the first element in a list? 0

31 Which keyword is used to create an anonymous function? lambda

32 Which method removes a specific element from a list? remove ()

33 What is the result of 10 % 3? 1

34 Which built-in function returns a list of integers? range ()

35 Which keyword is used for "if not" logic? else

36 Can a list contain different data types? Yes

37 What is the base of an octal number in Python? 8


No. Question Answer

38 Which module is used for mathematical operations? math

39 Which method splits a string into a list? split ()

40 What is the keyword for inheritance in class? (class name)

41 Which function generates a random number? random ()

42 What is the output of 2 * 3 ** 2? 18

43 Which method returns all keys in a dictionary? keys ()

44 Is range (5) inclusive of the number 5? No

45 What is a list of tuples called? Sequence

46 Which keyword creates an empty block? pass

47 Which operator checks if a value exists in a list? in

48 What is the name of the Python package manager? pip

49 Which method removes the last element of a list? pop ()

50 Does Python support multi-line strings? Yes

You might also like