Skip to main content

Posts

Showing posts from November, 2020
Welcome to  Git: Commit Amend - Basic (Java) . This question is used to evaluate your skills on creating a new branch and pushing it to remote in Git. For this, you will be evaluated based on the following operations. The remote repository has been pre-configured into your local git repository. Your local git repository will be  linkedlist_java . Push the master branch of local git repository to the remote repository. Create a new branch with the name  new_branch . Make a change to the Java program file (do not remove it), make a commit and push the branch. Amend the commit to change the commit message. Optionally, you can push it to remote. Note 1:  Do not miss out to run  Project -> Install . Note 2:  The branch names must not be mis-spelt. Note 3:  The IDE's Git will not work in the local repository. Use Terminal for it. ---------------------------------------------------------------------------------------------------...

HackerRank Question and Answer : Hands-on - List Operations

Basic List Operations   Write the function definition for the function ' List_Op ' which takes 2 parameters ' Mylist ' and ' Mylist2 ' both of which are LIST of INTEGERS   Do as per the following to get the expected output: 1.Print ' Mylist ' 2.Print the 1st element of  ' Mylist ' 3.Print the Last  element of  ' Mylist ' 4.Add '3' as the Last element of ' Mylist ' 5.Change the 4th element of ' Mylist ' into '60' 6.Print ' Mylist ' again 7.Print from the ' 2nd ' element to the ' 5th ' element of ' Mylist ' 8.Append ' Mylist2 ' to ' Mylist ' 9.Print ' Mylist ' again 10.Extend ' Mylist ' using ' Mylist2 ' 11.Print ' Mylist ' again 12.Remove the Last element of ' Mylist ' 13.Print ' Mylist ' again 14.Print ' Length ' of ' Mylist '   Input Format for Custom Tes...

Hands-on - String Operations Part 2

Python - String Operations 2   Rajesh is trying to write a program that will evaluate and correct his resume.   Define a function called ` resume ` which takes eight parameters . All the  parameters are string .     The first parameter first is the first name. the second parameter  second is the second name the third parameter  parent is the name of the father or mother the fourth parameter  city is the name of the city the fifth parameter contains phone number in the format of string the sixth and seventh parameter contains a single string the eigth parameter contains string sentence.   The function definition code stub is given in the editor. Generate print statements   based on conditions given below:   Remove the spaces from both the end for the strings (first, second, parent, city) Capitalize the first word for the strings (first, second, parent) print the stri...

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

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...
Math Operations - Float   Rakul started learning Python3 to participate in the upcoming " CodeChamp " which is an University level coding competition which can provide some special privileges in the recruitment drives for the next 2 years only for those who make it to the " Top-100 ".His enthusiasm started falling when he find it difficult to understand the Mathematical operations involving " FLOAT ".Help him to understand that easily.   Write the function definition for the function " Float_fun " which takes three parameters - ' f1' which is a FLOAT Variable - ' f2'  which is also a FLOAT Variable & - ' Power ' is an INTEGER   Do the following and Print the Output as per the Sample Test Case : 1.Print "#Add" 2.Add 'f1' and 'f2' and Print it 3.Print "Subtract" 4.Subtract 'f2' from 'f1' and Print it 5.Print "Multiply" 6.Mult...

HackerRank Hands-on - Using float

Python - Using Float 1   Sanjay is trying to help vijay to find the Area of a Triangle. But for some reason he is trying to find some relation between area and pi. let's help him find that based on the condition below. Function `triangle` takes three parameters called `n1`,'n2' as float and 'n3' as integer. Formula for Area:(n1*n2) /2 Return both values Area and Pi rounded off to 'n3' decimal places. NOTE: You can get the value of pi from math module.   Input Format for Custom Testing:   Input from stdin will be processed as follows and passed to the function.   The first line contains an float  n1 , the Height of the triangle. The second line contains an float  n2 , the base of the triangle. The third line contains an integer 'n3' which specifies the number of decimal places to be rounded off.   Sample Case 0 Sample Input STDIN      Function -----     ...

Hacker Rank using int math opeartor

Area & Volume   Sunil had an assignment on "Areas & Volumes" given by his Mathematics Teacher.He was given 1.' Side ',from which he have to find - Area of Square & - Volume of Cube 2.' Radius '   ,from which he have to find - Area of Circle & - Volume of Sphere 3." pi " equals to 3.14   Write the function definition for the function '' Integer_Math " which takes two arguments ' Side ' and ' Radius '   Print the Areas and Volumes as per the Sample Test Case below.   Input Format for Custom Testing: # In the first line, value for 'Side' # In the second line, value for 'Radius'   Note: -The outputs must be rounded off to two decimal places -Use round() for rounding off     -Example : round(123.45555, 2) is 123.46   Sample Test Case 1:   Sample Input STDIN      Function parameter -----      ------------------ 5 → Side 7 ...

HackerRank Handson - Python - Using Int operations

Python - Using Int operations   Define a function called ` find`  which takes three parameters .  The first parameter is ` num1 ` , the second parameter is ` num2` and the last parameter is 'num3' .   The function definition code stub is given in the editor. Print the output of comparison of the numbers in the parameters based on condition given below:   In the First print statement check if num1<num2 and num2>=num3 In the Second print statement check if num1>num2 and num2 <=num3 In the Third print statement check if num3==num1 and num1!=num2 Every output must be separated by a single space.   Constraints The output must be of boolean format. Input Format Format for Custom Testing   In the first line  num1  given In the second line  num2  given In the second line  num3  given     Sample Case 0   ...

Python Hacker Rank question and answer --Hands-on - Using int

Python - Integer   Write the function definition for the function ' Integer_fun ' which takes two parameters ' a' & ' b'  where  - a is a FLOAT variable & - b is a STRING variable which takes Integer input but as a String, Say b = "100".   Using type conversion, - Covert ' a ' into an INTEGER and store it in ' c ' - Covert ' b ' into an INTEGER and store it in ' d '    The Expected output is as below :  Print the Type of a  Print the Type of b Print c Print d Print the Type of c Print the Type of d   Input Format for Custom Testing: # In the first line, value for 'a' # In the second line, value for 'b'   Sample Test Case 1:   Sample Input STDIN      Function parameter -----      ------------------ 1.23 → a 562 → b   Sample Output <class 'float'> <class 'str'> 1 562 <class 'int...

Python Hacker Rank question and answer --Hands-on - Usage Imports

Python - Usage imports   Define a function called ` calc` which takes one parameter . The parameter 'c' is an integer which is the circumference of the circle .   The function definition code stub is given in the editor. Find the radius and Area of the circle using math module based on condition given below:   Formula for Radius: Area:   Return both Radius and Area.   The values must be rounded off to 2 positions. Constraints input must be an integer. Input Format Format for Custom Testing   In the first line c   given. Sample Case 0   Sample Input STDIN      Function -----      -------- 8       → c = 8 Sample Output (1.27, 5.09)  Explanation With 8 as input, Radius and Area are calculated and returned.   Answer: #!/bin/python3 import  math impor...

Python Hacker Rank question and answer --Hands-on - Namespaces 2

Python - Input from the user   Write the function definition for the function ' Prompt ' to get a ' STRING ' input from the user. Write a script to prompt the question " Enter an STRING: ". Pass the user input in a variable, Say 'x'.   Print the value of 'x' and its type in separate lines.   Input Format for Custom Testing: It’s a single line that contains string input from the user.   Sample Test Case 1:   Sample Input STDIN     ----- One Sample Output Enter a STRING: One <class 'str'>   #!/bin/python3 import  math import  os import  random import  re import  sys # # Complete the 'Prompt' function below. # # def  Prompt():      # Write your code here      print (  'Enter a STRING:' )     x = ''      print ( input (x))...

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

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 → ...