0% found this document useful (0 votes)
11 views

Python

Uploaded by

riju2bs8
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Python

Uploaded by

riju2bs8
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

localhost:8888/notebooks/B40%2OPython%20Test%o201%20Set%20A.

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.

Input Specification: First input is a single character. Second input is a sentence.


Output Specification Print the position numbers in a string seperated by space at where that character appears in the senitence
If the character does not appears in the sentence at all, print -1. Assume, first position of the sentence is1 and print position numbers separated by
spaces. Checking should be irrespective of case.

Sample Input 1: iths is lgnite


Sample Output 1:369 12
Sample Input 2: s ilove Python
Sample Output '1"

In [108]:@evaluate
def find_the_positions(c,s):
#hrite your code here

return c

Cell In[108], 1ine 5


if(a = i this is Ignite)

SyntaxError: invalid syntax

In [ ]: find the positions ("i","this is. Ignite")

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

Sample Input "ym eman Si nhOj"


Sample Output: "My Name ls John"

In 137]: @evaluate
def reverse 1t(n) :

#write your code here


reverse it-n.split(" ")
n=reverse it.append()
n.isLower()
n=reverse it[::-1]
printn

return n

File <tokenize>:12
return n

IndentationError: unindent does not match any outer indentation level

In [128]: reverse_ it("ym eman Si nhoj")

TypeError Iraceback (most recent call last)


Cell In[128], 1ine 1
---’ 1 reverse it("ym eman Si nhoj")

File ~\AppData\ Roaming\Python \Python39\site-packages\evaluator\evaluator. py:186, in evaluate.clocals>.cal led(*args, **kuargs)


184 t =_(test get('name'))

Type here to search


localhost:8888/notebooks/B409%20Python %20Test%201%20Set%20A.ipynb A
Logout
CJupyter B40 Python Test 1 Set A Last Checkpoint 101/2024 (autosaved)
Hle Edit View Insert Cell Kernel Widgets Help Trusted |Python 3 (ipykernel) o
Run Markdown

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.

Sample Input 1: hixoxhi


Sample Output: 1
Sample Input 2:xaxoxaxaxx
Sample Output:1

In [ ]: @evaluate
def basic_strings_6(s):
#write your code here

return None

In [ ]: basic_strings_6("hhixxhi")

In [ ]: basic strings_6("hixxhi", test='Basic Strings 6')

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

Output Specification: print \n to separate each word

Sample input:-4 hell troy barb team


Expected output - htbtlneraelnloranlybm

In [ ]: @evaluate
def exittest2 1(n):
#vrite your code here:

return None

In [ ]: exittest2_ 1(input() )

In [ ]:exittest2_1(input (), test='ExitTest2-1')

Question 5: Consolidating consonants


Given a string or sentence as input, write a program to count the number of consonants in the input. Your program takes a set of characters
(alphabetic, space, punctuation, special charactrs like $,%, &, ..)terminated with a RETURN and outputs an integer that stands for the number of
consonants in the input string. Input is 250 charácters long (excluding RETURN) at most.

Sample input:- Ranga &Radha Chartered Accountants Co


Expected output:- 20
9:07 PM
o Type here to search a )
10/23/2024
O localhost:8888/notebooks/B40%20Python%20Test%201%20Set%20A.ipynb
Jupyter B40 Python Test 1SetA Last Checkpoint 1011/2024 (autosaved) Logout

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

Sample input- Ranga &Radha Chartered Accountants Co


Expected output:- 20

In [ ]:@evaluate
def consolidating consonants(n):
#rite your code here

return None

In [138]:consolidating consonants (input ())

NameError Traceback (most recent call last)


Cell In[138], line 1
-> 1 consolidating consonants(input ())

NameError: name 'consolidating consonants ' is not defined

In [139]:consolidating consonants (input() , test='Consolidating consonants')

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

In [1401:# Submit the test before the stop time. 9:07 PM


a )
10/23/2024
O Type here to search

You might also like