21 solutions available
Question 1Write a Python script that traverses through an input string and prints its characters in different lines — two characters per line.
Question 5Can you say strings are character lists? Why? Why not?
Question 3Carefully go through the code given below and answer the questions based on it :theStr = " This is a test " inputStr = input("...
Question 4Carefully go through the code given below and answer the questions based on it :testStr = "abcdefghi" inputStr = input...
Question 5Carefully go through the code given below and answer the questions based on it :inputStr = input(" Give me a string:") biglnt = 0 littlelnt...
Question 6Carefully go through the code given below and answer the questions based on it :in1Str = input(" Enter string of digits: ") in2Str =...
Question 7aFind the output if the input string is 'Test'.S = input("Enter String :") RS = " " for ch in S : RS = ch + RS print(S + RS)
Question 8bFind the errors. Find the line numbers causing errors.S = "PURA VIDA"S1 = S[: 10] +S[10 :]S2 = S[10] + S[-10]
Question 8cFind the errors. Find the line numbers causing errors.S = "PURA VIDA"S1 = S * 2S2 = S1[-19] + S1[-20]S3 = S1[-19 :]
Question 8dFind the errors. Find the line numbers causing errors.S = "PURA VIDA"S1 = S[: 5]S2 = S[5 :]S3 = S1 * S2S4 = S2 + '3'S5 = S1 + 3
Question 9What is the output produced?(i) >>> "whenever" .find("never")(ii) >>> "whenever" .find("what")
Question 10What is the output produced?(i) >>> "-".join(['123','365','1319'])(ii) >>> " ".join(['Python', 'is', 'fun'])
Question 11Given a string S, write expressions to printfirst five characters of SNinth character of Sreversed Salternate characters from reversed S
Question 2Write a program which replaces all vowels in the string with '*'.Solutionstr = input("Enter the string: ") newStr = "" for ch in str :...
Question 3Write a program which reverses a string and stores the reversed string in a new string.Solutionstr = input("Enter the string: ") newStr =...
Question 4Write a program that prompts for a phone number of 10 digits and two dashes, with dashes after the area code and the next three numbers....
Question 6Write a program that should prompt the user to type some sentence(s) followed by "enter". It should then print the original sentence(s) and...
Question 7Write a Python program as per specifications given below:Repeatedly prompt for a sentence (string) or for 'q' to quit.Upon input of a...
Question 8Write a program that does the following :takes two inputs : the first, an integer and the second, a stringfrom the input string extract all...
Question 14Write a program to input a line of text and print the biggest word (length wise) from it.Solutionstr = input("Enter a string: ") words =...
Question 15Write a program to input a line of text and create a new line of text where each word of input line is reversed.Solutionstr = input("Enter...