St.
Mary’s University
Faculty of Informatics
Department of Computer Science
Introduction to Artificial Intelligence
Basics of Python programming practice questions
N.B.: Attempt all the practice questions in groups of 4 students and submit the solutions
as a bound hard copy by December 25, 2024.
1. Write a program that asks the user for two numbers and prints their sum, difference, product,
and quotient.
2. Write a program that checks whether a given number is even or odd.
3. Write a program that checks if a number is prime.
4. Write a program that takes a string and returns it reversed.
5. Write a program that counts the number of vowels in a given string.
6. Write a program that removes duplicate elements from a list.
7. Write a program that finds the maximum and minimum values in a list.
8. Write a program that generates and prints a random number between 1 and 100.
9. Write a program that calculates simple interest given principal, rate, and time.
10. Write a program that converts a temperature from Celsius to Fahrenheit.
11. Write a program that counts the number of words in a given sentence.
12. Write a program that finds and prints the length of a list.
13. Write a program that calculates the sum of the digits of a given number.
14. Write a program that creates a dictionary from two lists: one for keys and one for values.
15. Write a program that merges two dictionaries into one.
16. Write a program that checks if two strings are anagrams of each other.
17. Write a program that calculates the area of a circle given its radius.
18. : Write a function that prints the multiplication table of a given number.
19. : Write a program that finds and prints common elements in two lists.
20. Write a program that counts and displays the frequency of each element in a list.