PYTHON
PROGRAMMING
ASSIGNMENT
Coding Exercises
Exercise 1: Prime Numbers
Write a Python program that checks whether a given number is prime or not. A
prime number is a natural number greater than 1 that has no positive divisors other
than 1 and itself.
Exercise 2: Product of Random Numbers
Develop a Python program that generates two random numbers and asks the user to
enter the product of these numbers. The program should then check if the user's
answer is correct and display an appropriate message.
Exercise 3: Squares of Even/Odd Numbers
Create a Python script that prints the squares of all even or odd numbers within the
range of 100 to 200. Choose either even or odd numbers and document your choice
in the code.
Exercise 4: Word counter
write a program to count the number of words in a given text.
example:
input_text = "This is a sample text. This text will be used to demonstrate the word
counter."
Expected output:
'This': 2
'is': 1
'a': 1
'sample': 1
'text.': 1
Exercise 5: Check for Palindrome
Write a Python function called is_palindrome that takes a string as input and returns
True if the string is a palindrome, and False otherwise. A palindrome is a word,
phrase, number, or other sequence of characters that reads the same forward and
backward, ignoring spaces, punctuation, and capitalization .
Example:
Input: "racecar"
Expected Output: True
Please complete the coding exercises and answer the theoretical questions. Submit
your work in a single Python (.ipynb) file for the coding [Link] your code is
well-commented to explain your logic and approach. Good luck!