0% found this document useful (0 votes)
17 views

Lab 1

This document provides 15 practice questions on Python programming concepts like lists, tuples, dictionaries, sets, strings, math operations, random numbers, arrays, and combining different data structures. The questions cover creating, manipulating, and applying operations on various data types.

Uploaded by

deepakkvkur83
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Lab 1

This document provides 15 practice questions on Python programming concepts like lists, tuples, dictionaries, sets, strings, math operations, random numbers, arrays, and combining different data structures. The questions cover creating, manipulating, and applying operations on various data types.

Uploaded by

deepakkvkur83
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

LAB-1: Introduction to Google Colab and Jupyter Notebook

Practice Questions for Python Programming


1. Lists

o Create a list of 10 integers. Write a program to find the maximum and minimum
numbers in the list.

o Write a program to reverse a list of integers without using the reverse() method.

2. Tuples

o Create a tuple with 5 elements and write a program to convert it into a list.

o Write a program to find the second largest number in a tuple of integers.

3. Dictionaries

o Create a dictionary with 5 key-value pairs where keys are strings and values are
integers. Write a program to find the key with the highest value.

o Write a program to merge two dictionaries.

4. Sets

o Create two sets of integers. Write a program to find the union and intersection of
these sets.

o Write a program to check if a set is a subset of another set.

String Operations

5. String Manipulation

o Write a program to count the number of vowels in a given string.

o Write a program to check if a string is a palindrome.

6. String Formatting

o Write a program to format a string to display the first 3 characters and the last 3
characters of a string.

o Write a program to replace all occurrences of a given substring in a string with


another substring.

Math Operators

7. Basic Arithmetic

o Write a program to perform addition, subtraction, multiplication, and division of two


numbers input by the user.

o Write a program to calculate the area of a circle given its radius.

8. Advanced Math Operations


o Write a program to calculate the factorial of a number using a loop.

o Write a program to solve a quadratic equation given coefficients a, b, and c.

Random Number Generators

9. Random Numbers

o Write a program to generate a list of 5 random integers between 1 and 100.

o Write a program to simulate a simple dice roll (generate a random number between
1 and 6).

Arrays (using numpy)

10. Array Creation and Operations

o Create a numpy array with 10 elements. Write a program to find the mean and
standard deviation of the elements in the array.

o Write a program to multiply two numpy arrays element-wise.

11. Array Reshaping

o Create a 1D numpy array of 12 elements. Write a program to reshape it into a 3x4


matrix.

o Write a program to flatten a 2D numpy array into a 1D array.

Array Operations

12. Element-wise Operations

o Write a program to add and subtract two numpy arrays element-wise.

o Write a program to compute the dot product of two numpy arrays.

13. Array Indexing

o Create a 5x5 numpy array with random integers between 1 and 100. Write a program
to extract the diagonal elements of the array.

o Write a program to replace all even numbers in a numpy array with -1.

14. Combination of Structures

o Write a program to create a dictionary where the keys are the first 10 letters of the
alphabet and the values are random integers between 1 and 100.

o Write a program to create a list of tuples where each tuple contains a number and its
square for numbers from 1 to 10.

15. String and List Combination

o Write a program to find the common characters between two strings.

o Write a program to sort a list of strings based on the length of the strings.

You might also like