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

  1. These three words will be read one at a time, in three separate line
  2. The first word should be changed like all vowels should be replaced by *
  3. The second word should be changed like all consonants should be replaced by @
  4. The third word should be changed like all char should be converted to upper case
  5. 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

94 comments on “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”


  • subhojit

    #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)


  • prateek

    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))


  • Subham

    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))


  • Darren

    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)


  • Satya Sai Srija

    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=”)


  • Febin

    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())


  • Chandu

    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())


  • Harish

    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))


  • Joshini

    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??


      • Prashant

        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)


  • saikumarreddy

    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)


    • HelpPrepInsta

      thank you for contributing the answer Sai Kumar Reddy, but there is a small error in this code. It is not accepting the input


      • shilpa

        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)


  • ganesh

    Sir can you give me explanation of above programming for better understanding any video of that or link?


    • HelpPrepInsta

      Sorry Ganesh we don’t have a dedicated video for the above code, but the explanation is pretty simple
      Understand it in this way

      • the code is accepting 3 strings as the input.
      • all the vowels of the first string are replaced with *
      • all the consonants of the second string are replaces with @
      • all the alphabets of the third string are converted into uppercase
      • and then finally, all the three converted strings are concatenated into one string and printed on the screen

      • swati

        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)


  • Thanveer

    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))