Lab2-Python1

This lab will show how to use raw_input, assign the value, and print out the value

Source Code

numStr1 = input(‘Please enter your first number: ‘)
intVar1 = int(numStr1)
numStr2 = input(‘Please enter your second number: ‘)
intVar2 = int(numStr2)
print (‘The sum of ‘,intVar1,’ and ‘, intVar2,’ is ‘,intVar1+intVar2)
print (‘The different of ‘,intVar1,’ and ‘, intVar2,’ is ‘,intVar1-intVar2)
print (‘The product of ‘,intVar1,’ and ‘, intVar2,’ is ‘,intVar1*intVar2)
print (‘The quotient of ‘,intVar1,’ and ‘, intVar2,’ is ‘,intVar1//intVar2,
‘ with remainder is ‘, intVar1%intVar2)

Source Code of numberInput.py

# -*- coding: utf-8 -*-
“””
Created on Fri Aug 04 07:29:57 2012

@author: Prof. Benito Mendoza, PhD
Department of Computer Engineering Technology
New York City College of Technology
“””

inputStr = input(‘Please enter a numb ‘)
inputInt = int(inputStr)

print (‘When you multiply ‘,inputInt,’ times ‘,inputInt,’ you get: ‘,inputInt * inputInt)
print (‘This value correspond to your number to the power of two (squared).’)
print ()

print (‘Python has an operator to raise a number to any power. It is the ** operator.’)
print (‘This is the syntax <your number> ** <the power>. For example 5 ** 2 would result in 25.’)
print (‘This is the results of ‘, inputInt, ‘ square using the ** operator ==> ‘, inputInt ** 2)
print  ()

print (‘You should try to print you number rasied to other power, for example print your number cubed.’)