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”


  • S

    x=input()
    y=input()
    l=[“e”,”a”,”i”,”o”,”u”]
    for i in x:
    if i in l:
    x=x.replace(i,”*”)
    for i in y:
    if i not in l:
    y = y.replace(i, “*”)
    print(x,y)


  • rahul

    a=[]
    p=[‘a’,’e’,’i’,’o’,’u’,’A’,’E’,’I’,’O’,’U’]
    for i in range(3):
    a.append(input())
    for i in a[0]:
    if (i==’A’ or i==’a’ or i==’E’ or i ==’e’ or i==’I’ or i==’i’ or i==’O’ or i==’o’ or i==’U’ or i==’u’):
    a[0]=a[0].replace(i,’*’)

    for i in a[1]:
    if (i==’A’ or i==’a’ or i==’E’ or i ==’e’ or i==’I’ or i==’i’ or i==’O’ or i==’o’ or i==’U’ or i==’u’):
    continue
    else:
    a[1]=a[1].replace(i,’@’)
    a[2]=a[2].upper()
    print(a[0]+a[1]+a[2])


  • shivangi

    a=input().lower()
    b=input().lower()
    c=input().lower()
    x=list(a)
    y=list(b)
    vowels=(‘a’,’e’,’i’,’o’,’u’)
    for i in range(len(x)):
    if x[i] in vowels:
    x[i]=’*’
    a=”.join(x)
    for i in range(len(y)):
    if not y[i] in vowels:
    y[i]=’@’
    b=”.join(y)
    c=c.upper()
    result=a+b+c
    print(result)


  • mekala

    Mekala Sekhar python code:
    import time
    start=time.time()
    l=[]
    for i in range(3):
    l.append(input())

    k=l[0]
    k1=l[1]
    k2=l[2]
    l1=[“a”,’e’,’i’,’o’,’u’]

    for char in l1:
    if char in k:
    m=k.replace(char,”*”)
    k=m
    else:
    pass

    for i in range(len(k1)):
    if k1[i] in l1:
    pass
    else:
    p=k1.replace(k1[i],”@”)
    k1=p

    print(k+k1+k2.upper())
    end=time.time()
    total=end-start
    print(total)


  • Prashant

    Prashant java code using Strings:
    import java.util.*;
    public class words1 {
    public static void main(String args[])
    {
    Scanner sc=new Scanner(System.in);
    String a=sc.nextLine();
    String b=sc.nextLine();
    String c=sc.nextLine();
    String d=” “;String e=” “,;
    d=a;e=b;
    //first string
    int la=a.length();
    for(int i=0;i<la;i++)
    {char ch=a.charAt(i);
    if(ch=='a'||ch=='A'||ch=='o'||ch=='O'||ch=='i'||ch=='I'||ch=='e'||ch=='E'||ch=='u'||ch=='U') {
    d= d.replace(d.charAt(i),'*');
    }
    }//Second string
    int lb=b.length();
    for(int j=0;j<lb;j++)
    {char cha=b.charAt(j);
    if(!(cha=='a'||cha=='A'||cha=='o'||cha=='O'||cha=='i'||cha=='I'||cha=='e'||cha=='E'||cha=='u'||cha=='U')) {
    e= e.replace(e.charAt(j),'@');
    }
    }//third string
    c=c.toUpperCase();
    //Printing
    System.out.println(d+e+c);

    }
    }


  • Varagani

    divya #pythoncode
    first_word = input(“Enter your first text:”)
    result = “”
    for c in range(len(first_word)):
    char = first_word[c]
    if char ==’a’or char ==’e’or char ==’i’ or char ==’o’ or char ==’u’:
    result = result + ‘%’
    else:
    result = result + char

    second_word =input(“Enter your second text:”)
    for c in range (len(second_word)):
    char = second_word[c]
    if char ==’b’ or char ==’c’ or char ==’d’ or char ==’f’ or char ==’g’ or char ==’h’ or char ==’j’ or char ==’k’ or char ==’l’ or char ==’m’ or char ==’n’ or char ==’o’ or char ==’p’ or char ==’q’ or char ==’r’ or char ==’s’ or char ==’t’ or char ==’v’ or char ==’w’ or char ==’x’ or char ==’y’ or char ==’z’:
    result = result + ‘#’
    else:
    result = result + char
    third_word =input(“Enter your third text:”)
    result =result+ third_word.upper()
    print(result)


  • DIVYA

    python solution:
    s1=input()
    s2=input()
    s3=input()
    l=””
    for i in s1:
    if i in (‘a’,’e’,’i’,’o’,’u’):
    l=l+’*’
    else:
    l=l+i
    for i in s2:
    if i not in (‘a’,’e’,’i’,’o’,’u’):
    l=l+’@’
    else:
    l=l+i
    l=l+s3.upper()
    print(l)


  • Sreeja

    python code:
    n1=input()
    finalstr=””
    vowels=”aeiou”
    for i in n1:
    if i in vowels:
    finalstr+=”*”
    else:
    finalstr+=i

    n2=input()
    for i in n2:
    if i not in vowels:
    finalstr+=”@”
    else:
    finalstr+=i

    n3=input()

    finalstr+=n3.upper()
    print(finalstr)


  • Dipanjan

    Code in python passing both the test cases:
    s1=input()
    s2=input()
    s3=input()
    vowels=’AaEeIiOoUu’
    res=”
    digits=’1,2,3,4,5,6,7,8,9′
    for i in range(len(s1)):
    if(s[i] in vowels):
    s1=s1.replace(s1[i],’%’)

    for i in range(len(s2)):
    if(s2[i] in vowels) or (s2[i] in digits):
    continue
    else:
    s2=s2.replace(s2[i],’#’)

    s3=s3.upper()
    res=s1+s2+s3
    print(res)


  • Thanveer

    Sorry for that in the last comment i forgot to validate whether they are number in case on consonents. cant find any option to edit or delete comment in this thread

    def takeword(word, choice):
    vowel = [‘a’, ‘e’, ‘i’, ‘o’, ‘u’]
    nums = [‘0’, ‘1’, ‘2’, ‘3’, ‘4’, ‘5’, ‘6’, ‘7’, ‘8’, ‘9’]

    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 and word.isalpha():
    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))


  • Thanveer

    Python code

    def takeword(word, choice):
    vowel = [‘a’, ‘e’, ‘i’, ‘o’, ‘u’]
    conso = []
    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))


  • Zaid

    p = str(input())
    q = str(input())
    r = str(input())

    A = [“A”,”E”,”I”,”O”,”U”,”a”,”e”,”i”,”o”,”u”]

    for i in p:
    if i in A:
    p = p.replace(i,”*”)

    for j in q:
    if j not in A:
    q = q.replace(j,”@”)

    r = r.upper()

    print(p+q+r)