Lab 2

Featured

This is Lab 2. In this lab, I used the two variables “a” and “b”. I made it so that the user/programmer inputs a value for “a” and “b” then the program runs an operation to find the Sum,Difference,Product,Quotient, and the Remainder of the assigned values. This program also indicates whether the first value is greater than the second value and vice versa. It also determines if the values are the same. I enjoyed exploring python and seeing what its capabilities are. The program I worked on felt like I was making a graphing calculator.

Here is the code i used for the program:

# This is our first script
# Program to operate on two integers a and b

a_str=raw_input(‘Please Enter a Number: ‘)

b_str=raw_input(‘Please Enter Second Number: ‘)

a=int(a_str)

b=int(b_str)
#This is the processing stage
my_sum = a+b

my_difference=a-b

my_product=a*b

my_quotient=a/b

my_remainder=a%b

#This is the output stage

print (‘The sum of my numbers is: ‘,my_sum)

print (‘The difference of my numbers is: ‘,my_difference)

print (‘The product of my numbers is: ‘,my_product)

print (‘The quotient of my numbers is: ‘,my_quotient)

print (‘The remainder of my numbers is: ‘,my_remainder)

if a>b:
print(‘The first value is greater than the 2nd. ‘)

elif a<b:
print(‘The 2nd value is greater than the 1st. ‘)

else:
print(‘Both values are the same ‘)

And here are some screenshots of the results of the program and the code i used:

Hello world!

This is the first post on your Learning Blog. Edit or delete it, then start blogging!

NOTE: Remember to add appropriate Category and Tags to your posts. This will help your professors and other visitors find the content they are looking for. The Category “Coursework” and the Tags “OpenLab” and “City Tech” have already been applied to this post. Feel free to make changes!