Hackerearth's python problems solutions( Jadoo vs Koba, Jadoo and DNA Transcription, Jadoo Hates Numbers, 13 Reasons Why, Chacha!! O Chacha ) :

Problem 1: Jadoo vs Koba

Solution: (in python 3.8)


( please guys before moving to the solution try it yourself at least 3-4 times , if you really wanna become a good coder)


for i in range(ord('F'),ord('Q')): #see note below
print(i)
 

ord() function returns the ASCII value of a character inside it's parenthesis. You can also wrap up this question in one line using list comprehensions:

 

[print(i) for i in range(ord('F'),ord('Q'))]
 


 

 

 

 

Problem 2: Jadoo and DNA Transcription

Solution: (in python 3.8)


( please guys before moving to the solution try it yourself at least 3-4 times , if you really wanna become a good coder)

s = input()
for i in s:
    if i!="G" and i!="C" and i!="T" and i!="A":
        print("Invalid Input")
        exit()
for i in s:
    if i=="G":
        print("C",end="") #see note below
    elif i=="C":
        print("G",end="")
    elif i=="T":
        print("A",end="")
    else:
        print("U",end="")

The print function signature is:

print(*object , sep = ' ' , end = '\n' , file = sys.stdout , flush = False) 

here sep means how you want to seperate the variables , by default its value is a single space.

For example -

a = 12

b = 34

print(a,b)   # 12 34

print(a,b,sep="|")    # 12|34

print(a,b,sep="")   # 1234

In the function end means how you want to end your print statement , by default its value is \n i.e next line. Continuing the above example:

print(a)

print(b)   # 12

                  34


print(a , end=" ")

print(b)                     # 12 34


In this way you can use sep and end in the print function.


 

 

Problem 3: Jadoo Hates Numbers

Solution: (in python 3.8)

( please guys before moving to the solution try it yourself at least 3-4 times , if you really wanna become a good coder)

print(ord('F')+ord('F')+ord('F')+ord('F')+ord('F')+ord('F'))
 

This code is simple. There's no need for any explanation.
 

 

 

 

 

Problem 4: 13 Reasons Why

Solution: (in python 3.8)

( please guys before moving to the solution try it yourself at least 3-4 times , if you really wanna become a good coder)

p=input().split(" ") # the input is a string and using .split(" ") will
# make a list of numbers present in the string 
a,b,c=int(p[0]),int(p[1]),int(p[2])
temp=a # swapping a and b values using temp
a=b
b=temp
a=a*c
b=b+c
print(a,b,sep=" ") # see above problem number 2 to know what's the use of sep here

This code is simple. There's no need for any explanation.

 

 

 

 

 

Problem 5: Chacha!! O Chacha

Solution: (in python 3.8)

( please guys before moving to the solution try it yourself at least 3-4 times , if you really wanna become a good coder)

 print('captcha')

 

Explanation: since chacha doesn't like to download the movies , he automated the task. To prevent use of automation captcha is used. Like you have seen sometimes you have to enter what's written in the image containing twisted or blurry letters. This is done to check you are not a bot. Since bots can't understand these things.

how to submit: click the submit button directly , don't click compile and test.




 

Guys, if you have any queries related to a question or need more explanation for a question , comment below!

Moreover, i can suggest you best blogging website for latest technologies/products/services update.

Comments

Popular posts from this blog

Coursera's Algorithmic toolbox assignment solutions( Sum of Two Digits, Maximum Pairwise Product ) :

HackerEarth's basic programming solutions( Seating Arrangement, Zoos, Anagrams ) :

HackerEarth's basic programming solutions( Minimize Cost, Magical Word, Best Index ) :