-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathadd_two_numbers.py
More file actions
28 lines (24 loc) · 1021 Bytes
/
add_two_numbers.py
File metadata and controls
28 lines (24 loc) · 1021 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
################################################################################
#
# Program: Sum Two Numbers From User Input
#
# Description: Add together two numbers that have been provided from user input
# with Python.
#
# YouTube Lesson: https://www.youtube.com/watch?v=X5IMiLsbieM
#
# Author: Kevin Browne @ https://portfoliocourses.com
#
################################################################################
# Use input() to prompt the user with the text "Number 1: ", the user will then
# be given a chance to enter in a string. When the user enters a string and
# hits enter it will be returned from input, but to get the number value inside
# of the string we use float() to convert it to a floating-point number (a
# number that may have decimal places), and we store the result into number1.
number1 = float(input("Number 1: "))
# Do the same thing with number2
number2 = float(input("Number 2: "))
# Sum the numbers
sum = number1 + number2
# Output the resulting sum
print("Sum:", sum)