30 Day code challenge-python

Ganesh Uthiravasagam
2 min readMar 8, 2021

--

Day 1 — Data Types

Task

Declare 3 variables: one of type int, one of type double, and one of type String.

Read 3 lines of input from stdin (according to the sequence given in the Input Format section below) and initialize your 3 variables.

Use the + operator to perform the following operations:
→Print the sum of I plus your int variable on a new line.
→Print the sum of d plus your double variable to a scale of one decimal place on a new line.
→Concatenate s with the string you read as input and print the result on a new line.

Sample input and output

Input Format

The first line contains an integer that you must sum with i.
The second line contains a double that you must sum with d.
The third line contains a string that you must concatenate with s.

Output Format

Print the sum of both integers on the first line, the sum of both doubles (Float) (scaled to 1 decimal place) on the second line, and then the two concatenated strings on the third line.

Solution

Explanation

The first three lines of code are pre-built by HackerRank IDE.
The next three lines get input from the user which stores an integer, float (doubles) and string.
Finally, the next three lines print the concatenation (join) value of corresponding data types.

Bonus Tip: we cannot add a string and an integer but multiplication is possible.

See you on day 2

--

--

No responses yet