CS 115 Lab
Exam 1 preparation
Summer 2017
Exam Instructions:
- The exam is open book, and open notes.
- You are not allow to talk to anybody or contact anybody.
- The exam contains two problems.
- The time for the exam is 55 minutes.
- Zip the files for the two problems together as one. Use your last name to name your zip file.
- Submit your zip files using CANVAS at the link of Lab Exam.
- In case you did not finish your work submit whatever you had done for partial credit.
When you
have completed the lab and submitted on CANVAS make
sure you do the following:
1.Sign the attendance sheet
2.Show the instructor a picture ID
3.Have the instructor verify that you
have successfully submitted your solution
Problem1: (50 points) Compare numbers
Write a program that reads two numbers, make sure in your program that both the numbers are greater than 50, If the user enter any of the numbers less than 50
show an error message saying "These numbers are small, you should do it in your head". If the two numbers are greater than 50, then compare the two numbers and show one of the three messages:
The two numbers are equal
X-value is greater than y-value
y-value is greater than x-value
Run Examples
When you have the program running correctly, Verify that your program produces the same output as in the following test cases.
--- Test case 1 ---
Enter the first number: 5
Enter the second number: 20
These numbers are small
--- Test case 2 ---
Enter the first number: 65
Enter the second number: 70
70 is greater than 65
Problem2: (50 points)
Write a python program to read integer value N from the user, you program should make sure that N is not a negative value and N is not Zero,
then show all the values that is divisible by 3 without a reminder
in the range (N,2*N) where N and 2*N is considered in the range.
Run Examples
When you have the program running correctly, Verify that your program produces the same output as in the following test cases.
--- Test case 1 ---
Enter the first number: 20
21 in the range (20,40) is divisible by 3
24 in the range (20,40) is divisible by 3
27 in the range (20,40) is divisible by 3
30 in the range (20,40) is divisible by 3
33 in the range (20,40) is divisible by 3
36 in the range (20,40) is divisible by 3
39 in the range (20,40) is divisible by 3
--- Test case 2 ---
Enter the first number: -5
N has invalid value
Program Prolog
For every of the problem above, provide prolog explaining your information
# supply program prolog
# Prolog
# Author: Mary Smith
# Email: Mary.Smith@uky.edu
# Section: 00
# Date: 7/7/16
Requirments:
1- Choose names for your variables that make sense, do not use short names consist of one letter. Use good, multi-character, meaningful identifiers (variables) names.
2- Your output should match the run examples provided with the problems above.
3- Document your work by putting comments at the top of your program, remember that comments in python are either:
starts with # in case the comment is one line only or ''' and ''' if the comment is taking more than one line.
4- At the top of your program, you should have a prolog (name, date, etc.)
When you are done with the two problems, you can show it to instructor if you want, but you don't have to. This lab is to practice before the exam.