String Number Add

String Number Add

Easy Python Data Types 11 views
Explanation Complexity

Problem Statement

A number is provided as a string x and an integer y is provided. Convert x to int and output x+y.

Input Format

• First line: A string x (represents an integer)

• Second line: Integer y

Output Format

• Print one integer: result of int(x) + y

Example

123
7
130

Constraints

• x is a valid integer string

• -10^9 ≤ int(x), y ≤ 10^9

Concept Explanation

Input:
x = "123"
y = 7

Convert "123" to integer → 123
Add 7 → 123 + 7 = 130

Output is 130

Step-by-Step Explanation

1.Read string x.

2.Read integer y.

3.Convert x to integer using int(x).

4.Compute result = converted value + y.

5.Print the result.

Concept Explanation

Input:
x = "123"
y = 7

Convert "123" to integer → 123
Add 7 → 123 + 7 = 130

Output is 130

Step-by-Step Explanation

1.Read string x.

2.Read integer y.

3.Convert x to integer using int(x).

4.Compute result = converted value + y.

5.Print the result.

Input / Output Format

Input Format
• First line: A string x (represents an integer)

• Second line: Integer y
Output Format
• Print one integer: result of int(x) + y
Constraints
• x is a valid integer string

• -10^9 ≤ int(x), y ≤ 10^9

Examples

Input:
123 7
Output:
130

Example Solution (Public)

Python
import sysnp=sys.stdin.read().strip().split()nif not p: sys.exit(0)nx=int(p[0])ny=int(p[1])nsys.stdout.write(str(x+y))

Official Solution Code

import sysnp=sys.stdin.read().strip().split()nif not p: sys.exit(0)nx=int(p[0])ny=int(p[1])nsys.stdout.write(str(x+y))
Please login to submit solutions.
Editor
Output

                                        
Please login to submit solutions.