0% found this document useful (0 votes)
3 views1 page

Python Questions

The document outlines various programming tasks involving string manipulation in Python. Tasks include converting strings to title case, trimming spaces, checking string prefixes and suffixes, replacing substrings, splitting strings, using variables in print statements, checking for palindromes, validating username lengths, detecting the presence of the word 'error', and determining the case of characters in a string. Each task requires specific code implementations and outputs based on the given conditions.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Python Questions

The document outlines various programming tasks involving string manipulation in Python. Tasks include converting strings to title case, trimming spaces, checking string prefixes and suffixes, replacing substrings, splitting strings, using variables in print statements, checking for palindromes, validating username lengths, detecting the presence of the word 'error', and determining the case of characters in a string. Each task requires specific code implementations and outputs based on the given conditions.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Given name = "hello world", write code to convert it to title case and print

the result.

Given text = " Python is fun ", remove the leading and trailing spaces and
print the length of the cleaned string.

Write code to check if the string "Artificial Intelligence" starts with "Art"
and ends with "nce". Print both results.

Given sentence = "the cat sat on the mat", replace every occurrence of
"at" with "og" and print the result.

Split the string "apple,banana,mango,grape" by comma and print the third


item in the resulting list.

Use print: "My name is Ananya and I am 25 years old." using variables
name and age.

Write a program that takes a string word and prints "Palindrome" if it


reads the same forwards and backwards, otherwise prints "Not a
palindrome".

Given a string username, print "Valid" if its length is between 6 and 12


characters (inclusive), otherwise print "Invalid".

Write a program that checks if a given string contains the word "error"
(case-insensitive). Print "Error found" or "All good".

Given a string s, print "All uppercase" if every character is uppercase, "All


lowercase" if every character is lowercase, or "Mixed case" otherwise.

You might also like