# Complete this assignment by editing this file replacing appropriate comments
# with your code. When you are complete, running this file should compute
# with no errors and print the correct solutions to the stated problems.
import random # This makes the random number functions available
# Problem 1
print("\n\nProblem 1 Solution:\n")
num_one= int(input("Please enter the first number:", ))
num_two= int(input("Please enter the second number:", ))
num_thr= int(input("Please enter the third number:", ))
print("The sum is: \t\t" + str(int(num_one + num_two + num_thr)))
print("The average is: \t" + str(int(num_one + num_two +num_thr)/3))
print("The product is: \t" + str(int(num_one * num_two * num_thr)))
largest_number = num_one
if((num_one >= num_two) and (num_one >= num_thr)):
largest_number = str(num_one)
elif((num_two >= num_one) and (num_two >= num_thr)):
largest_number = str(num_two)
else:
largest_number = str(num_thr)
print("The largest number is: \t" + largest_number)
smallest_number= num_one
if(num_one <= num_two) and (num_one <= num_thr):
smallest_number= str(num_one)
elif((num_two <= num_one) and (num_two <= num_thr)):
smallest_number = str(num_two)
else:
smallest_number = str(num_thr)
print("The smallest number is:\t" + smallest_number)
# Problem 2
print("\n\nProblem 2 Solution:\n")
import math
print("number \t square \t cube \n")
num=0
while (num < 11):
print(num, '\t' , pow(num, 2), '\t', pow(num, 3))
num +=1
# Problem 3
print("\n\nProblem 3 Solution:\n")
food = str(876320)
while(len(food) > 5 or len(food) < 5):
food = str(input("please enter a list of (5) digits: "))
if len(food) > 5:
print("Too may digits")
elif len(food) < 5:
print("Too few digits")
else:
print(food[0], "\t", food[1], "\t", food[2], "\t", food[3], "\t",
food[4])
# Problem 4
print("\n\nProblem 4 Solution:\n")
rows = int(input("How many rows should be displayed?: "))
# Name: [Victoria Ogunnubi]
# CIS 235
# Python Homework
print("n\t10*n\t100*n\t1000*n")
for x in range(1, rows + 1):
print(str(x) +"\t" + str(x*10) + "\t" + str(x*100) + "\t" + str(x*1000))
# Problem 5
print("\n\nProblem 5 Solution:\n")
num_guess = int(input("Guess a number between 1 and 10: "))
from random import randint
com_num = randint(1,10)
guesses = 2
if com_num == num_guess:
print("You win!")
else:
while num_guess != com_num:
guesses = guesses + 2
num_guess = int(input("Guess a number between 1 and 10: "))
if num_guess == com_num:
print("You win!\nIt took you " + str(guesses) + " guesses to win. Good
Job!")
# Problem 6
print("\n\nProblem 6 Solution:\n")
print("You have four chances to guess the number!\n")
num_guess = int(input("Guess a number between 1 and 10: "))
from random import randint
com_num = randint(1,10)
guesses = 1
if num_guess != com_num:
num_guess = int(input("Guess a number between 1 and 10: "))
guesses = guesses + 1
if num_guess == com_num:
print("You win!\nIt took you " + str(guesses) + " guesses to win. Good
Job!")
elif num_guess != com_num:
num_guess = int(input("Guess a number between 1 and 10: "))
guesses = guesses + 1
if num_guess == com_num:
print("You win!\nIt took you " + str(guesses) + " guesses to win. Good
Job!")
elif num_guess != com_num:
num_guess = int(input("Guess a number between 1 and 10: "))
guesses = guesses + 1
if num_guess == com_num:
print("You win!\nIt took you " + str(guesses) + " guesses to win. Good
Job!")
if num_guess != com_num:
print("Too bad! Play Again!")
Powered by TCPDF (www.tcpdf.org)