- 0
Notifications Mark All Read
- Login
- Get Prime
TCS Coding 1. The program will recieve 3 English words inputs from STDIN These three words will be read one at a time, in three separate line
1. The program will recieve 3 English words inputs from STDIN
- These three words will be read one at a time, in three separate line
- The first word should be changed like all vowels should be replaced by *
- The second word should be changed like all consonants should be replaced by @
- The third word should be changed like all char should be converted to upper case
- Then concatenate the three words and print them
Other than these concatenated word, no other characters/string should or message should be written to STDOUT
For example if you print how are you then output should be h*wa@eYOU.
You can assume that input of each word will not exceed more than 5 chars
Test Cases
Case 1
Input
- how
- are
- you
Expected Output : h*wa@eYOU
Case 2
Input
- how
- 999
- you
Expected Output : h*w999YOU
C
C++
C
#include<stdio.h> #include<conio.h> #include<string.h> int main() { int i; char a[100],b[100],c[100]; scanf("%s",a); scanf("%s",b); scanf("%s",c); for(i=0;a[i]!='\0';i++) { if(a[i]=='a'||a[i]=='e'||a[i]=='i'||a[i]=='o'||a[i]=='u'||a[i]=='A'||a[i]=='E'||a[i]=='I'||a[i]=='O'||a[i]=='U') a[i]='*'; } for(i=0;b[i]!='\0';i++) {
if((b[i]>='a'&&b[i]<='z') || (b[i]>='A'&&b[i]<='Z')) if(!(b[i]=='a'||b[i]=='e'||b[i]=='i'||b[i]=='o'||b[i]=='u'||b[i]=='A'||b[i]=='E'||b[i]=='I'||b[i]=='O'||b[i]=='U')) b[i]='@'; } for(i=0;c[i]!='\0';i++) { if(c[i]>='a'&&c[i]<='z') c[i]=c[i]-32; } printf("%s%s%s",a,b,c); return 0; }
C++
#include<iostream> #include<string.h>
using namespace std;
int main() { int i; char a[100],b[100],c[100]; cin >> a; cin >> b; cin >> c; for(i=0;a[i]!='\0';i++) { if(a[i]=='a'||a[i]=='e'||a[i]=='i'||a[i]=='o'||a[i]=='u'||a[i]=='A'||a[i]=='E'||a[i]=='I'||a[i]=='O'||a[i]=='U') a[i]='*'; } for(i=0;b[i]!='\0';i++) {
if((b[i]>='a'&&b[i]<='z') || (b[i]>='A'&&b[i]<='Z')) if(!(b[i]=='a'||b[i]=='e'||b[i]=='i'||b[i]=='o'||b[i]=='u'||b[i]=='A'||b[i]=='E'||b[i]=='I'||b[i]=='O'||b[i]=='U')) b[i]='@'; } for(i=0;c[i]!='\0';i++) { if(c[i]>='a'&&c[i]<='z') c[i]=c[i]-32; } cout << a << b<< c; return 0; }
Login/Signup to comment
#Python Code
v={‘A’,’E’,’I’,’O’,’U’,’a’,’e’,’i’,’o’,’u’}
s1,s2,s3=list(input()),list(input()),input()
s1f,s2f=””,””
for i in s1:
if i in v:
s1f+=”*”
else:
s1f+=str(i)
for i in s2:
if i in v:
s1f+=str(i)
elif i.isdigit():
s1f+=str(i)
else:
s1f+=”@”
s3=s3.upper()
print(s1f+s2f+s3)
easy way to solve this code
n=input()
m=input()
o=input()
l=[]
vowel=[‘a’,’e’,’i’,’o’,’u’,’A’,’E’,’I’,’O’,’U’]
for i in n:
if i in vowel:
i=’*’
l.append(i)
else:
l.append(i)
for j in m:
if j in vowel:
j=’@’
l.append(j)
else:
l.append(j)
for k in o:
if k.islower()==True:
k=k.upper()
l.append(k)
elif k.isupper()==True:
l.append(k)
print(”.join(l))
def concatenation_string(input1,input2,input3):
v=[‘a’,’e’,’i’,’o’,’u’]
S1=input1.lower()
S2=input2.lower()
for i in S1:
if i in v:
S1=S1.replace(i,”*”)
for j in S2:
if j not in v:
S2=S2.replace(j,”@”)
input3=input3.upper()
return S1+S2+input3
n1=input(“enter your string:\n”)
n2=input(“enter your string:\n”)
n3=input(“enter your string:\n”)
print(concatenation_string(n1,n2,n3))
python code for the above pgm
a=input(‘1: ‘)
b=input(‘2: ‘)
c=(input(‘3. ‘)).upper()
j=[‘a’,’e’,’i’,’o’,’u’,’A’,’E’,’I’,’O’,’U’]
for i in a:
if i in j:
a=a.replace(i,’*’)
for i in b:
if i not in j:
b=b.replace(i,’*@’)
print(a+b+c)
char2=input()
char3=input().upper()
char1=list(char1)
char2=list(char2)
S=”
T=”
for i in range(0,len(char1)):
if char1[i] in [‘a’,’e’,’i’,’o’,’u’,’A’,’E’,’I’,’O’,’U’]:
char1[i]=’*’
S=S+char1[i]
for i in range(0,len(char2)):
if char2[i] in [‘b’,’B’,’c’,’C’,’d’,’D’,’f’,’F’,’g’,’G’,’h’,’H’,’j’,’J’,’k’,’K’,’l’,’L’,’m’,’M’,’n’,’N’,’p’,’P’,’q’,’Q’,’r’,’R’,’s’,’S’,’t’,’T’,’v’,’V’,’w’,’W’,’x’,’X’,’y’,’Y’,’z’,’Z’]:
char2[i]=’@’
T=T+char2[i]
print(S,end=”)
print(T,end=”)
print(char3,end=”)
str1=str(input())
str2=str(input())
str3=str(input())
v=[‘a’,’e’,’i’,’o’,’u’]
for i in str1:
if i in v:
str1=str1.replace(i,’*’)
for i in str2:
if i not in v:
str2=str2.replace(i,’#’)
print(str1+str2+str3.upper())
str1=str(input())
str2=str(input())
str3=str(input())
s=””
for i in range(len(str1)):
if str1[i] in “aeiou”:
s=s+”*”
else:
s=s+str1[i]
for i in range(len(str2)):
if str2[i] in “aeiou” or str2[i].isdigit():
s=s+str2[i]
else:
s=s+”@”
print(s+str3.upper())
I think this python code might be correct!
import string
alphabet_string = string.ascii_lowercase
alphabet_list = list(alphabet_string)
n=list(map(str,input()))
k=list(map(str,input()))
l=list(map(str,input()))
vow=[‘a’,’e’,’i’,’o’,’u’]
ans=[]
for item in n:
if item in vow:
ans.append(‘*’)
else:
ans.append(item)
for item in k:
if item in alphabet_list:
if item in vow:
ans.append(item)
else:
ans.append(‘@’)
else:
ans.append(item)
for item in l:
ans.append(item.upper())
print(”.join(ans))
Hey Harish, thanks for contributing the code
will tcs recruit python coder??
Yes, they surely will
Python code
word1=input()
word2=input()
word3=input()
vowel=[“a”,”e”,”i”,”o”,”u”]
for i in word1.lower():
if(i in vowel):
word1=word1.replace(i,”*”)
for j in word2.lower()
if(j in vowel):
word2=word2.replace(j,”@”)
word3=word3.upper()
fin=word1+word2+word3
print(fin)
will tcs recruit python coder??
Thanks for contributing the code Joshini
a small change
word1=input()
word2=input()
word3=input()
vowel=[“a”,”e”,”i”,”o”,”u”]
for i in word1.lower():
if(i in vowel):
word1=word1.replace(i,”*”)
for j in word2.lower():
if(j not in vowel):
word2=word2.replace(j,”@”)
word3=word3.upper()
fin=word1+word2+word3
print(fin)
python code for above problem:
a=input(“enter first string”)
v=[‘a’,’e’,’i’,’o’,’u’]
b=input(“enter second string”)
c=input(“enter third string”)
for i in a:
if i in v:
u=(a.replace(i,’*’))
a=u
for i in b:
if i not in v:
v=(b.replace(i,’@’))
b=u
for i in c:
w=c.replace(i,chr(ord(i)-32))
c=w
FINAL=u+v+w
print(FINAL)
thank you for contributing the answer Sai Kumar Reddy, but there is a small error in this code. It is not accepting the input
Python code
a = “how”
b = “are”
c = “you”
vowels = (‘a’,’e,”i’,’o’,’u’)
const =(‘b’,’c’,’d’,’f’,’g’,’h’,’j’,’k’,’l’,’m’,’n’,’p’,’q’,’r’,’s’,’t’,’v’,’w’,’x’,’y’,’z’)
for x in a:
if x in vowels:
a = a.replace(x,”*”)
for x in b:
if x in const:
b = b.replace(x,”@”)
for x in c:
c = c.upper()
print(a,b,c)
Sir can you give me explanation of above programming for better understanding any video of that or link?
Sorry Ganesh we don’t have a dedicated video for the above code, but the explanation is pretty simple
Understand it in this way
Python Code for python Version 3.8.5:
a=input(“Enter First String:”)
b=input(“Enter Second String:”)
c=input(“Enter Third string:”)
for i in a:
if i in [‘a’,’e’,’i’,’o’,’u’]:
a=a.replace(i,’*’)
for i in a:
if i in [‘A’,’E’,’I’,’O’,’U’]:
a=a.replace(i,”*”)
for i in b:
if i in [‘b’,’c’,’d’,’f’,’g’,’h’,’j’,’k’,’l’,’m’,’n’,’p’,’q’,’r’,’s’,’t’,’v’,’w’,’x’,’y’,’z’]:
b=b.replace(i,’@’)
for i in b:
if i in [‘B’,’C’,’D’,’F’,’G’,’H’,’J’,’K’,’L’,’M’,’N’,’P’,’Q’,’R’,’S’,’T’,’V’,’W’,’X’,’Y’,’Z’]:
b=b.replace(i,’@’)
for i in c:
c=c.upper()
print(a+b+c)
def takeword(word, choice):
vowel = [‘a’, ‘e’, ‘i’, ‘o’, ‘u’]
if choice == 1:
for let in word:
if let in vowel:
word = word.replace(let, “*”)
return word
elif choice == 2:
for let in word:
if let not in vowel:
word = word.replace(let, “@”)
return word
elif choice == 3:
word = word.upper()
return word
x = input(“enter first string”)
y = input(“enter the third string”)
z = input(“enter the second number”)
print(takeword(x, 1)+takeword(y, 2)+takeword(z, 3))