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”


  • Raja

    python code using regular expression
    import re
    a = input()
    b = input()
    c = input()
    print((re.sub(‘[aeiouAEIOU]’,’*’,a))+(re.sub(‘[^aeiou0-9]’,’@’,b))+(c.upper()))


  • Sourav

    Python Code:
    a = str(input())
    b = str(input())
    c = str(input())

    v = [‘a’,’e’,’i’,’o’,’u’]
    con = [‘b’,’c’,’d’,’f’,’g’,’h’,’j’,’k’,’l’,’m’,’n’,’p’,’q’,’r’,’s’,’t’,’v’,’w’,’x’,’y’,’z’]
    for i in a:
    if i in v:
    x = a.replace(i,’*’)
    for i in b:
    if i in con:
    y = b.replace(i,’@’)
    else:
    y = b
    z = c.upper()

    print(x+y+z)


    • Sai

      a = str(input())
      b = str(input())
      c = str(input())
      x, y, z = 0, 0, 0
      vowels = [“a”, “e”, “i”, “o”, “u”]
      consonents = [“b”, “d”, “f”, “g”, “h”, “j”, “k”, “l”, “m”, “n”, “p”, “q”, “r”, “s”, “t”, “v”, “w”, “x”, “y”, “z”]
      for i in a:
      if i in vowels:
      x = a.replace(i, “*”)
      for i in b:
      if i in consonents:
      y = b.replace(i, “@”)
      else:
      y = b
      z = c.upper()
      print(x+y+z)
      thanks for the code, but you forgot to intialize x, y, z to “0”, now it works.


  • shashank

    w1 = input()
    w2 = input()
    w3 = input()

    vowels = [“a”, “e”, “i”, “o”, “u”]
    nums = [‘1’, ‘2’, ‘3’, ‘4’, ‘5’, ‘6’, ‘7’, ‘8’, ‘9’, ‘0’]

    w1 = [item for item in w1]
    for i in range(len(w1)):
    if w1[i] in vowels:
    w1[i]=”*”
    w1 = ”.join([str(elem) for elem in w1])

    w2 = [item for item in w2]
    for i in range(len(w2)):
    if w2[i] not in vowels and w2[i] not in nums:
    w2[i]=”@”
    w2 = ”.join([str(i) for i in w2])

    w3 = w3.upper()

    print(w1+w2+w3)


  • alojyoti

    a = input()
    b = input()
    c = input()
    vowels = [‘A’, ‘E’,’I’,’O’,’U’]
    for char in a:
    if char.upper() in vowels:
    a = a.replace(char, ‘%’)
    for char in b:
    if ord(char.upper()) > 65 and ord(char.upper()) < 91 and char.upper() not in vowels:
    b = b.replace(char, '#')
    c = c.upper()
    print(a+b+c)


  • alojyoti

    import re
    a = input()
    b = input()
    c = input()
    a = re.sub(r”([aeiouAEIOU])”,’%’,a)
    b = re.sub(r”([b-df-hj-np-tv-zB-DF-hJ-NP-TV-Z])”,’#’,b)
    c = c.upper()
    print(a+b+c)


  • alojyoti

    See the magic of python:

    import re
    a = input()
    b = input()
    c = input()

    a = re.sub(r”([aeiouAEIOU])”,’%’,a)

    b = re.sub(r”([b-df-hj-np-tv-zB-DF-hJ-NP-TV-Z])”,’#’,b)

    c = c.upper()

    print(a+b+c)


  • Gaurav

    word1 = input(“”)
    word2 = input(“”)
    word3 = input(“”)
    vowels = [“a”, “e”, “i”, “o”, “u”]
    for i in word1:
    if i in vowels:
    word1 = word1.replace(i, “*”)
    for i in word2:
    if i not in vowels:
    word2 = word2.replace(i, “@”)
    print(word1+word2+word3.upper())


  • Deepak

    a=str(input())
    b=str(input())
    c=str(input())
    vowel={‘a’,’e’,’o’,’u’,’i’,’A’,’E’,’O’,’U’,’I’}
    digit={‘0′,’1′,’2′,’3′,’4′,’5′,’6′,’7′,’8′,’9′}
    for x in a:
    if x in vowel:
    a=a.replace(x,’*’)
    for y in b:
    if(y not in vowel and y not in digit):
    b=b.replace(y,’#’)
    c=c.upper()
    print(a+b+c)


  • Varun

    w1=[x for x in input().lower()]
    w2=[x for x in input().lower()]
    w3=input().lower()

    vowwels=[‘a’,’e’,’i’,’o’,’u’]
    for i in range(0,len(w1)):
    if w1[i] in vowwels:
    w1[i]=”*”
    s1=””.join(w1)

    for i in range(0,len(w2)):
    if w2[i] not in vowwels and (w2[i].isdigit==False):
    w2[i]=”@”
    s2=””.join(w2)

    s3=w3.upper()

    print(s1+s2+s3)


  • Bharath

    import string
    word1=input()
    word2=input()
    word3=input()
    vowel=[“a”,”e”,”i”,”o”,”u”]
    alphabet=[“b”,”c”,”d”,”f”,”g”,”h”,”j”,”k”,”l”,”m”,”n”,”p”,”q”,”r”,”s”,”t”,”v”,”w”,”x”,”y”,”z”]
    alphabet_string = string.ascii_lowercase
    alphabet_list=list(alphabet_string)
    for i in word1.lower():
    if i in vowel:
    word1=word1.replace(i,”%”)
    for j in word2.lower():
    if j in alphabet:
    word2=word2.replace(j,”#”)
    word3=word3.upper()
    result=word1+word2+word3
    print(result)


  • Sudipta

    w1 = input()
    w2 = input()
    w3 = input()
    vowel_dic = {‘a’, ‘e’, ‘i’, ‘o’, ‘u’}
    for char in w1:
    if char in vowel_dic:
    vowel_dic.remove(char)
    w1 = w1.replace(char, ‘*’)
    for char in w2:
    if char.isalpha() and char not in vowel_dic:
    w2 = w2.replace(char, ‘@’)
    w3 = w3.upper()
    print(w1+w2+w3)


  • Darshan

    EASY c++ code
    #include
    using namespace std;

    int main()
    {
    string a,b,c; cin>>a>>b>>c;
    for(int i=0;i<a.size();i++)
    {
    if(a[i]=='a' || a[i]=='e' || a[i]=='i' || a[i]=='o' || a[i]=='u')a[i]='%';
    }
    for(int i=0;i=97 && b[i]<=122))b[i]='#';
    }
    for(int i=0;i<c.size();i++)c[i]-=32;
    cout<<a<<b<<c;
    }