The document outlines a series of Python exercises divided into three parts: Lists, Strings, and Combined Exercises. Each part contains specific tasks that require user input and involve operations such as calculating sums, finding minimum values, checking for palindromes, and manipulating strings. The exercises aim to enhance the user's understanding of Python programming through practical applications.
The document outlines a series of Python exercises divided into three parts: Lists, Strings, and Combined Exercises. Each part contains specific tasks that require user input and involve operations such as calculating sums, finding minimum values, checking for palindromes, and manipulating strings. The exercises aim to enhance the user's understanding of Python programming through practical applications.
a. Ask the user to input a list of numbers. b. Calculate and print the sum of all elements in the list. 2. Find the smallest element in a list a. Ask the user to input a list of numbers. b. Find and print the smallest number in the list. 3. Check if an element exists in a list a. Ask the user to input a list and a number to search for. b. Check if the number exists in the list and print a message indicating whether the number is present or not. 4. Reverse a list a. Ask the user to input a list of numbers. b. Print the list reversed (without using the .reverse() method). 5. Merge two lists a. Ask the user to input two lists of numbers. b. Merge these two lists into one and print the result. 6. Count the occurrences of an element in a list a. Ask the user to input a list of numbers. b. Also ask for a number to search for and print how many times it appears in the list. 7. Create a list of squares of elements a. Ask the user to input a list of numbers. b. Create a new list containing the squares of each element and print the new list.
Part 2: Strings (Character Arrays)
1. Count the number of vowels in a string
a. Ask the user to input a string of characters. b. Count and print the number of vowels (a, e, i, o, u) in the string. 2. Count the number of words in a string a. Ask the user to input a string of characters. b. Count and print the number of words in the string. (Consider that words are separated by spaces). 3. Check if a string is a palindrome a. Ask the user to input a string of characters. b. Check if the string is a palindrome (i.e., if it reads the same forwards and backwards). 4. Extract characters from a string at given indices a. Ask the user to input a string and a list of indices. b. Print the characters corresponding to these indices in the string. 5. Replace a word in a string a. Ask the user to input a string of characters, a word to replace, and a replacement word. b. Replace all occurrences of the word in the string and print the result. 6. Reverse a string a. Ask the user to input a string of characters. b. Print the reversed string (without using the .reverse() method). 7. Count occurrences of a character in a string a. Ask the user to input a string and a character to search for. b. Print how many times that character appears in the string.
Part 3: Combined Exercises
1. Work with a list of strings
a. Ask the user to input a list of strings. b. Print the length of each string in the list. 2. Analyze a sentence a. Ask the user to input a sentence. b. Print the sentence with each word in uppercase and also the sentence reversed. 3. Convert a list of strings into a single string a. Ask the user to input a list of strings. b. Merge all the strings in the list into one string, with a space between each element. 4. Check if two strings are anagrams a. Ask the user to input two strings. b. Check if the two strings are anagrams (i.e., if they contain the same characters, but in a different order).