Today we will see the HackerRank Day 1 Solution in Python. The problem is named Data Types which is part of 30 Days of code on HackerRank. Let’s get started!
Day 1: Data Types Problem statement
We are given three variables which already been declared and initialized. The given three variables are of type int, double, and String. Our task is to declare and get input of three more variables one of type int, one of type double, and one of type String. Then we have to Print the sum of the int variable on a new line, print the sum of the double variable on a new line, and, print the concatenation of the strings on a new line.
12 4.0 is the best place to learn and practice coding!
16 8.0 HackerRank is the best place to learn and practice coding
When we sum the integers 4 and 12, we get the integer 16. When we sum the floating-point numbers 4.0 and 12.0, we get 16.0. When we concatenate HackerRank with is the best place to learn and practice coding!, we get HackerRank is the best place to learn and practice coding!
HackerRank Day 1 Solution in Python
#Initialize integer, double, and String variables. i = 4 d = 4.0 s = 'HackerRank ' # Read and store an integer, double, and String to variables. input_int=int(input()) input_float=float(input()) input_str=str(input()) # Print the sum of both integer variables on a new line. print(i+input_int) # Print the sum of the double variables on a new line. print(d+input_float) # Concatenate and print the String variables on a new line print(s+input_str)
- First, we read and store an integer, double, and String to the variables as input_int, input_double, and input_string
- Then, we print the sum of both integer variables on a new line and print the sum of the double variables on a new line.
- Finally, concatenate and print the String variables on a new line
- HackerRank Day 8 Solution in Python: Dictionaries and Maps
- HackerRank Day 7 Solution in Python: Arrays
- HackerRank Day 6 Solution in Python: Let’s review
- HackerRank Day 5 Solution in Python: Loops
- HackerRank Day 4 Solution in Python: Class vs Instance
- HackerRank Day 3 Solution in Python: Intro to Conditional Statements
- HackerRank Day 2 Solution in Python: Operators
- HackerRank Day 1 Solution in Python: Data Types
- HackerRank Day 0 Solution in Python: Hello World
- HackerRank Day 29 Solution in Python: Bitwise AND
- HackerRank Day 28 Solution in Python: RegEx, Patterns, and Intro to databases
- HackerRank Day 27 Solution in Python: Testing
- HackerRank Day 26 Solution in Python: Nested Logic
- HackerRank Day 25 Solution in Python: Running Time and Complexity
- HackerRank Day 24 Solution in Python: More Linked Lists
- HackerRank Day 23 Solution in Python: BST Level Order Traversal
- HackerRank Day 22 Solution in Python: Binary Search Trees
- HackerRank Day 20 Solution in Python: Sorting
- HackerRank Day 19 Solution in Python: Interfaces
- HackerRank Day 18 Solution in Python: Queues and Stacks
- HackerRank Day 17 Solution in Python: More Exceptions
- HackerRank Day 16 Solution: Exceptions – String to Integer
- HackerRank Day 15 Solution in Python: Linked List
- HackerRank Day 13 Solution in Python: Abstract Classes
- HackerRank Day 14 Solution in Python: Scope
- HackerRank Day 12 Solution in Python: Inheritance
- HackerRank Day 11 Solution in Python: 2D Arrays
- HackerRank Day 10 Solution in Python: Binary Numbers