String – sample question for practice
1) Write a Python program that takes a user input string and prints it in uppercase and
lowercase.
2) Create a program that checks if a given string is entirely in uppercase or lowercase using the
isupper() and islower() methods.
3) Write a function that takes a string as input and returns True if it consists only of
alphanumeric characters (letters and numbers), otherwise returns False. Use the
isalnum() method.
4) Develop a Python program that takes two strings as input and concatenates them. Print the
result in both uppercase and lowercase.
5) Create a program that converts the first letter of each word in a given string to uppercase
using the title() method.
6) Write a program that takes a user input string, reverses it, and checks if the reversed string is
the same as the original. Use the [::-1] slicing technique.
7) Write a Python program that takes a sentence as input and prints the number of words in it
using the split() method.
8) Create a program that takes a list of words as input, joins them into a single string separated
by commas, and prints the result using the join() method.
Dictionary topic
1) Write a Python program to create a dictionary with at least five key-value pairs. Print the
dictionary.
2) Write a program that adds a new key-value pair to an existing dictionary and then updates
the value of an existing key.
3) Develop a program that takes a dictionary as input and prints lists of keys and values
separately.
4) Write a program that iterates through a dictionary and prints both keys and values using a
loop.
5) Develop a function that takes a dictionary and a key as input, removes the key from the
dictionary, and prints the modified dictionary.
File Management
1) Write a Python program that uses [Link]() to create a new directory named
"NewDirectory" in the current working directory.
2) Develop a program that uses [Link]() to remove the directory "NewDirectory"
3) Write a Python script that uses [Link]() to print the current working directory.
4) Write a Python program that uses [Link]() to print the user's home directory.
5) Write a Python program that prints the current working directory using both
[Link]() and [Link]().