Strings Problem Solving in Codekata using Python(7 - 15)

Опубликовано: 09 Июнь 2021
на канале: FORMAL INFINITY
5,717
42

Hey guys, Welcome to FORMAL INFINITY Channel, In this video we would discuss the solution for Codekata programing problems using python in Guvi. In this specific video we have discussed Input and Output related problems in Guvi. We would continue this series of video for covering all the topics under codekata.

If you find our videos useful, please like or comment and don't forget to subscribe our channel to follow frequent videos and regular updates posted in our channel.

Video link :    • Strings Problem Solving in Codekata using ...  
Subscribe: https://www.youtube.com/channel/UCPN5....

And If you haven't checked Playlists available in our channel, The link for all the available playlists is given below:

Strings : https://youtube.com/playlist?list=PLP...

Arrays : https://youtube.com/playlist?list=PLP...

Input & Output Functions : https://youtube.com/playlist?list=PLP...

Numbers : https://youtube.com/playlist?list=PLP...

If you have any queries related to problem solving (or) encounter difficulties while coding in Python, You may contact me through Gmail.

Contact id: askdoubtshere@gmail.com
_________________
Question_1:-
you are given a string made up of parenthesis only.Your task is to check whether parenthesis are balanced or not.If they are balanced print 1 else print 0

Sample Input :
{({})}
Sample Output :
1
*****************
n = input()
r = 0
m = 0
for i in n:
if i in '({[':
r += 1
if i in ')}]':
m += 1
if r == m:
print(1)
else:
print(0)
_________________
Question_2:-
In XYZ country there is rule that car’s engine no. depends upon car’ number plate. Engine no is sum of all the integers present on car’s Number plate.The issuing authority has hired you in order to provide engine no. to the cars.Your task is to develop an algorithm which takes input as in form of string(Number plate) and gives back Engine number.

Sample Input :
HR05-AA-2669
Sample Output :
28
**************
a = input()
r = 0
for i in a:
if i in ('1234567890'):
r = int(i)+r
else:
continue
print(r)
_________________
Question_3:-
Write a program to get a string S, Type of conversion (1 - Convert to Lowercase, 2 - Convert to Uppercase) T, and integer P . Convert the case of the letters in the positions which are multiples of P.(1 based indexing).

Sample Input :
ProFiLe
1
2
Sample Output :
Profile
******************
a = input()
T = int(input())
P = int(input())
arr = []
for i in a:
arr.append(i)
if T == 1:
for i in range(1, int(len(a)/P)+1):
arr[(P*i)-1] = arr[P*i-1].lower()
if T == 2:
for i in range(1, int(len(a)/P)+1):
arr[(P*i)-1] = arr[P*i-1].upper()
for i in arr:
print(i, end='')
_____________________
Question 4:-
Jennyfer is fond of strings. She wants to read the character from right to left (reverse the string), so she wants you to design a suitable algorithm which satisfy her desire.
Sample Input :
jennyfer
Sample Output :
Refynnej
*********************
a = input()
print(a[::-1].capitalize())
_____________________
Question 5:-
Given a string S, print it without using semicolon in your program.
Sample Testcase :
INPUT
hello world
OUTPUT
hello world
**********************
a = input()
print(a)
_____________________
Question 6:-
Given a string S, print 'yes' if it has a vowel in it else print 'no'.
Sample Testcase :
INPUT
codekata
OUTPUT
yes
*********************
a = input()
count = 0
for i in a:
if i in 'AEIOUaeiou':
count += 1
if count 'use grater than sign' 0:
print('yes')
else:
print('no')
____________________
Question 7:-
Given a string S, print it after changing the middle element to * (if the length of the string is even, change the 2 middle elements to *).
Sample Testcase :
INPUT
hello
OUTPUT
he*lo
********************
s = input()
d = len(s)//2
if len(s)%2 == 1:
print(s[0:d]+'*'+s[d+1:])
else:
print(s[0:d-1]+'**'+s[d+1:])
___________________
Question 8:-
You are given string ‘s’. Your task is to modify the string as mentioned below:-
1)The string should not have three consecutive same characters.
2)You can add any number of characters anywhere in the string. Find the minimum number of characters which Ishaan must insert in the string.

Sample Input :
aabbbcc
Sample Output :
1
******************
a = input()
arr = []
condition = 0
for i in a:
arr.append(i)
for i in range(len(a)-2):
if arr[i] == arr[i+1] and arr[i] == arr[i+2]:
condition += 1
print(condition)
__________________
Question 9:-
You are given a string ‘s’.Your task is to print the string in the order they are present and then sum of digits.
Sample Input :
AC30BD40
Sample Output :
ACBD7
*******************
a = input()
r = 0
arr = []
for i in a:
if i in '1234567890':
r += int(i)
else:
print(i, end='')
print(r)
_______________________
The later animation was sponsored by Videezy.com
Credits:
href="http://www.videezy.com" B Roll provided by Videezy.com
Free Stock Footage by href="http://www.videezy.com/" Videezy


На этой странице сайта вы можете посмотреть видео онлайн Strings Problem Solving in Codekata using Python(7 - 15) длительностью online в хорошем качестве, которое загрузил пользователь FORMAL INFINITY 09 Июнь 2021, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 5,717 раз и оно понравилось 42 зрителям. Приятного просмотра!