STRING
PROBLEM-
Write a program which takes a student's ID as input and check if the student is in CSE AI with Robotics branch or not. The student's year of admission can range from 2018 to 2021. . Matching must be case insensitive.
CODE-
a=input()
b=int(a[0:2])
if b in range(18,22):
c=a[2:5]
if c=='BRS' or c=='brs':
print('Yes')
else:
print('No')
else:
print('No')
OUTPUT-
--------------------------------------------------------------------------------------------------------------------------------
PROBLEMS-
Sruthi has got the task to slicing the string S with N charecters and she has to find no of VOWELs in each slice. Your task
is to help Sruthi to slice the given string S with N charecters and Display no of VOWELs each slice.
Input Format
is to help Sruthi to slice the given string S with N charecters and Display no of VOWELs each slice.
Input Format
First line contains a string s with out any spaces Second line contains integer N
Constraints:
string length <100
N<=10
Output Format:
print each slice and no of vowels line by line
print each slice and no of vowels line by line
Sample Input :
welcome
4
welcome
4
Sample Output :
welc: 1
elco: 2
lcom: 1
come: 2
welc: 1
elco: 2
lcom: 1
come: 2
CODE-
s=input()
n=int(input())
l=len(s)
vowels=0
for i in range(l-n+1):
c=s[i:i+n]
se=list(c)
for j in se:
if j=='a' or j=='e' or j=='i' or j=='o' or j=='u' or j=='A' or j=='E' or j=='I' or j=='O' or j=='U':
vowels+=1
print(c,':',vowels)
vowels=0
--------------------------------------------------------------------------------------------------------------------------------
PROBLEM-
Program to Count the Occurrences of each Word in a given Sentence/String.
Input Format:
Accept a string/Sentence and a word from the user.
Constraints:
Only Characters accepted.
Output Format:
Print the total count.
Sample Input :
hi hi bye hi bye
bye
Sample Output :
Count of the word is: 2
CODE-
a=input().split()
b=input()
c=0
for i in a:
if i==b:
c+=1
print("Count of the word is:",c)
OUTPUT-
--------------------------------------------------------------------------------------------------------------------------------------------------------
PROBLEM-
In a college students are playing a game in their activity class.they are given cards with words on them and then the
students have to sort them alphabetic order.Suma is a student in that class who is good in python programming. She
want to write a python program for this task your task is to help her.
Given S is a line of string with multiple words.Suma and you have to read the line of string and sort the words in
alphabetic order display them with lenth of each word.
students have to sort them alphabetic order.Suma is a student in that class who is good in python programming. She
want to write a python program for this task your task is to help her.
Given S is a line of string with multiple words.Suma and you have to read the line of string and sort the words in
alphabetic order display them with lenth of each word.
Input Format
single line of string
single line of string
Constraints
lenth of string>0
lenth of string>0
Output Format
print sorted words line by line with lengths
print sorted words line by line with lengths
Sample Input :
hello this is an example with cased letters
hello this is an example with cased letters
Sample Output :
The sorted words are:
an : 2
cased : 5
example : 7
hello : 5
is : 2
letters : 7
this : 4
with : 4
The sorted words are:
an : 2
cased : 5
example : 7
hello : 5
is : 2
letters : 7
this : 4
with : 4
CODE-
a=input().split()
a.sort()
for i in a:
print(i,":",len(i))
a.sort()
for i in a:
print(i,":",len(i))
OUTPUT-
--------------------------------------------------------------------------------------------------------------------------------
Comments
Post a Comment