Skip to main content

Hakcer Rank question and answer : Hands-on - Newline & Tab spacing

Newline and Tab Spacing & Raw String

 

Write the function definition for the function 'Escape', which takes 3 parameters s1, s2, s3, all of which are STRING variables.

 

Assign "Python\tRaw\nString\tConcept" to a STRING Variable 's'.

 

The expected output is as follows:

1. Print these 3 strings separated by a New Line

2. Print these 3 strings separated by a Tab Space

3. Print 's'

4. Print the Raw String of 's' 

 

Input Format for Custom Testing

# In the first line, value for 's1'

# In the second line, value for 's2'

# In the third line, value for 's3'

 

Sample Test Case 1

 

Sample Input

STDIN        Function parameter
-----        ------------------
Bahubali →   s1
is a     →   s2
Legend   →   s3  

 

Sample Output

Bahubali
is a
Legend
Bahubali    is a    Legend
Python    Raw
String    Concept
Python\tRaw\nString\tConcept

 




#!/bin/python3

import math
import os
import random
import re
import sys



#
# Complete the 'Escape' function below.
#
# The function accepts following parameters:
#  1. STRING s1
#  2. STRING s2
#  3. STRING s3
#

def Escape(s1, s2, s3):
    # Write your code here
    print(s1+'\n'+s2+'\n'+s3)
    print(s1+'\t'+s2+'\t'+s3)
    s = "Python\tRaw\nString\tConcept"
    print(s)
    print(r'Python\tRaw\nString\tConcept')

if __name__ == '__main__':
    s1 = input()

    s2 = input()

    s3 = input()

    Escape(s1, s2, s3)

Comments

Post a Comment

Popular posts from this blog

Python Hacker Rank Question and Answer -- Hands-on - Range

Python - Range1   Define a function called ` rangefunction ` which takes three parameters . The first parameter is ` startvalue ` , the next parameter is ` endvalue` and the last parameter is 'stepvalue' .   The function definition code stub is given in the editor. Generate the squares of numbers from ` startvalue ` to ` endvalue ` using range   based on condition given below:   Print the values which must be separated by tab spaces. Note: startvalue and endvalue both are inclusive in the range.    Constraints 1 ≤ startvalue Input Format for Custom Testing   In the first line  startvalue given In the second line endvalue given In the second line stepvalue given     Sample Case 0   Sample Input STDIN      Function -----      -------- 2       → startvalue = 2 9 → endvalue = 9 2 → ...

Python Hacker Rank question and answer -- String 01

Python - String Operations - 1   Define a function `stringoperation` that takes four parameters, namely 'fn', 'ln', 'para' as a string, and 'number' as an integer.   The function definition code stub is given in the editor. Generate the print statements based on the condition given as follows: First print: concat 'fn', 'number' times the number of newline character and 'ln' Second print: 'concat' 'fn' , tab space and 'ln' Third print: Prints the 'number' multiples of the string 'fn' Fourth print: Prints the 'para' string using f-string as follows: The sentence is {para}   Input Format for Custom Testing   The input from stdin will be processed as follows and passed to the function:   The first line contains a string 'fn' , the first name. The second line contains a string 'ln' , the last name. The third line contain...

Python Hacker Rank question and answer --HandsOn -- Print

Greeting Quote Mr.Greet is the name of the digital notice board placed at the entrance of the seminar hall.Its purpose is to welcome each and every participants of the seminar by showing a welcoming quote with their name on it. It is based on the function ‘ Greet ’ which takes a single parameter ‘ Name ’ as a String are the names of the participants as Input One by one. Write the function definition for ‘ Greet ’ which will generate the welcoming quote as below : For Example,the ‘ Name ’ is “Ramakrishnan” then the welcoming quote will be : Output: Welcome Ramakrishnan. It is our pleasure inviting you. Have a wonderful day.   Note: ‘ Name ’ must be of String Data type.   Input Format for Custom Testing: It’s a single line contains a name. Sample Test Case 1:   Sample Input STDIN      Function -----      -------- Karthik → Name Sample Output Welcome Karthik. It is our pleasure inviting yo...