Python
Python
ipynb A
Jupyter B40 Python Test 1 Set A Last Checkpoint 10/11/2024 (autosaved)
Logout
File Edit View Insert Gel Kemel Widgets Help Trusted Python 3(pykernel) O
Run
CMarkdown
ITIIUUIG VUOIUUIIN
Write a python program which takes acharacter and asentence as input. Print the position numbers where the character appears in that line. fthe
character does not appears in the sentence at all, print -1.
In [108]:@evaluate
def find_the_positions(c,s):
#hrite your code here
return c
In []: find the positions ("i", "this is Ignite", test='Find the positions')
9:06
a ) 10/23
Type here to search
localhost:8888/notebooks/ B4U%2UPyt 7020IESL7020
Jupyter B40 Python Test 1 Set A Last Checkpoint 10/11/2024 (autosaed) Logout
FHle Edit View Insert Cell Kemel Widgets Help Trusted Python 3 (ipykermel) O
Run Markdown
Question 2: Reverse It
letter)capitalized
Write a python program to reverse each word in the sentence and have each word's first letter (and only the first
In 137]: @evaluate
def reverse 1t(n) :
return n
File <tokenize>:12
return n
Question 3: CountRepeat
number of times the tail substring
Given aString., define its tail' as the substring containing the last 2 characters. Write a method to count the
occurs in the String. You must not count the last occurrence.
tail.
Output Specification: return the count of.the tail given in the string excluding the
Constraints: Once the alphabet is considered, don't consider it again.Check sample output 2.
In [ ]: @evaluate
def basic_strings_6(s):
#write your code here
return None
In [ ]: basic_strings_6("hhixxhi")
Question 4: ExitTest2-1
described below. The input to your program consists of:
**Write a Python program that will rearrange agiven set of words as
characters can be anything
separated N words and each word has exactly N characters. The
An integer in the first that specifies N and the space
except blank space.
first letter of each words and second word
words such that the firt word should contain all the
Your program should print the same number of
should be the second letter of each words and so on. 9:06 PVM
a )
10/23/2024
o Type here to search
localhost:8888/Jupyter
notebooks/B40%20Python%20Test%201%20Set%20A.ipynb
B40 Python Test1 Set ALast
Checkpoint 10/11/2024 (autosaved)
A
Logout
Fle Edi View Insert Cel Kemel Widgets Help
Trusted
Python 3 (ipykernel) O
Questuon 4: EXItIesZ-TRunCMarkdown
**Writea Python program that will rearrange a given set of words as
described below. The input to your program consists of:
An integer in the first that specifies N andthe space
except blank space.
separated N words and each word has exacttyN characters. The characters can be
anything
Your program should print the same number of words such that the firt
word should contain all the first letter of each words and
should be the second letter of each words and so on. second word
In [ ]: @evaluate
def exittest2 1(n):
#vrite your code here:
return None
In [ ]: exittest2_ 1(input() )
Hle Edit View Insert Cell Kermel Widgets Help Trusted Python 3(ipykernel) O
RunCMarkdown
Question 5: Consolidating consonants
Given a string or sentence as input, write a program to count the number of consonants in the input Your prograrn takes a set of characters
(alphabetic, space, punctuation, special characters like $,%, &,..)terminated with a RETURN and outputs an integer that stands for the number of
consonants in the input string. Input is 250 characters long (excluding RETURN) at most
In [ ]:@evaluate
def consolidating consonants(n):
#rite your code here
return None
NameError
Traceback (most recent call last)
Cell In[1391, line 1
--> 1 consolidating consonants (input(), test='Consolidating consonants')
NameError: name 'consolidating consonants' is not defined