# bool.py PseudoCode
# Program that uses functions to compare
# two numbers and return the boolean value.
# Declare the "compare" function
# pass the two values to the function
# compare the two values
# return the boolean value to the main program
def co
# mycalc.py
# simulate the operation of a calculator
# define the add function for 2 numbers
def add(x, y):
return x + y
# define the subtract function for 2 numbers
def subtract(x, y):
return x - y
# define the multiplication function for 2 numbers
def m
Test driven development (TDD) is a programming method that involves writing testing code before
writing functional code [Int13]. The idea is to write or refactor your program into small manageable
pieces and incrementally test the functionality of the cod
(add, subtract,
dvide, multiply)
Eantion =
NumberA
(operation)
Number B
Display Eanlion
END
Universiig of the People
Programming Assignment Unit 3
CS 1101 - T4 2013-2014
Prof. Curtis Vance
The calculator must prompt the userto enter
two numbers and an
W F
Python 2.7.6 (default, Nov 10 2013, 19:24:24) [MSG v.1500 64 bit: (AMDGQH on win
32
Type "copyright", "credits" or "license()' for more intonation.
>
The Area of my Triangle - 96.0
>
Unit 6 Assignment Code (example solution)
#
# Function to compare two numbers
#
def compare(a, b):
if a < b:
return -1
elif a > b:
return 1
elif a = b:
return 0
#
# a < b condition
retvalue = compare(2, 5)
print retvalue
#
# a > b condition
retvalue = com
Code of Calculator Program
# Calculator program: mycalc.py
# This program will compute the output of an
# operation (add, subtract, multiply, divide)
# Applied against two numbers that are input
#
# Initialize result variable
result = 0.0
# Prompt for fir
Unit 7 Assignment Solution
The file unsorted_fruits.txt (which is available in the resources section of this unit within
Moodle) contains a list of 26 fruits, each one with a name that begins with a different letter
of the alphabet.
Write a program named
tryme2.py
#
# this python program demonstrates the use of a function call including the
# ability to 'nest' function calls.
#
def new_line():
print
def three_lines():
new_line()
new_line()
new_line()
def nine_lines():
three_lines()
three_lines()
three_lin
Start
Prompt for
operation
Prompt for
first number
Yes
Yes
Add numbers
Is operation add
No
Is number 0
Yes
Subtract numbers
Is operation subtract
Prompt for
second number
No
Display numbers
Yes
Yes
Is number 0
Multiply numbers
Is operation multiply
No
No