CMPT 120 Lecture 5: Part 1: Programming

15 views2 pages
meghan78 and 39786 others unlocked
CMPT 120 Full Course Notes
29
CMPT 120 Full Course Notes
Verified Note
29 documents

Document Summary

Step 4 : declare a variable sum and initialize it to 0. Step 5 : get 1st number from user and store in n1. Step 6 : get 2nd number from user and store in n2. Step 7 : add n1 and n2, and store the answer in sum. Code: add two numbers n1 = 0 n2 = 0 sum = 0 n1 = input() n2 = input() sum = int(n1) + int(n2) print(sum) Step 2 : declare a variable n1 and initialize it to 0. Step 3 : declare a variable n2 and initialize it to 0. Step 4 : declare a variable n3 and initialize it to 0. Step 5 : declare a variable sum and initialize it to 0. Step 6 : get 1st number from user and store in n1. Step 7 : get 2nd number from user and store in n2. Step 8 : get 3rd number from user and store in n3.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents

Related Questions