Write a Python program to convert the characters to lowercase in a string. Write a Python program to uppercase characters in a string. Write a Python program to check if the string is a digit . Write a Python program to find the length of the string. Write a Python program to add 'ing' at the end of a given string .
Answers
1. Python program to convert the characters to lower case in a string.
s = input("Enter a string: ")
print(s.lower(), "is its Lower case form.")
- This has been done using an inbuilt function of Python, .lower() that converts any string value to lower case.
2. Python program to convert the characters to upper case in a string.
s = input("Enter a string: ")
print(s.upper(), "is its Upper case form.")
- This has been done using another inbuilt function of Python, .upper() that converts any string value to upper case.
3. Python program to check if the string is a digit.
s = input("Enter a string: ")
for i in s:
if i.isdigit():
print("The string has digit values.")
break
else:
print("The string does not have digit values.")
- This has been done using the .isdigit() function that checks for numerical values in a string.
4. Python program to check the length of a string.
s = input("Enter a string: ")
print(len(s), "is the length of the string.")
- len() is another function that calculates the length of a string.
5. Python program to add 'ing' at the end of a given string.
s = input("Enter a string: ")
print(s + "ing", "is the resultant string after adding 'ing' to it.")