SlideShare a Scribd company logo
1 of 24
Total Grade (30 pts)
COSC 1436 Weeks 5-6 Lab Assignment -3
Name (First Last):
Data Conversions and Control structures I
1. (3 points, each for 0.5 point ) Convert each of following
numbers to Octal numbers, showing all steps.
a. (111110110)2
b. (1100010)2
c. (2001)10
d. (1492)10
e. (A9)16
f. (5FF71 )16
2. (3 points, each for 0.5 point ) Convert each of following
numbers to Binary numbers, showing all steps.
a. (572) 8
b. (1604) 8
c. (1066)10
d. (99)10
e. (80E)16
f. (135AB)16
3. (3 points, each for 0.5 point ) Convert each of following
numbers to Hexadecimal numbers, showing all steps.
a. (1111 0111)2
b. (1010 1010 1010)2
c. (777) 8
d. (443) 8
e. (998)10
f. (1066)10
4. (3 points, each for 0.5 point ) Evaluate the following
expressions. For each expression, keep the same number system
as it is. Do not convert the number systems. E.g. if the
expression is written using hexadecimal number system, your
answer should also be written in hexadecimal number system.
a. (1110 1111)2+(1011 1101)2
b. (11000001)2-(100010)2
c. (202) 8+( 667) 8
d. (1066)16+ (ABCD)16
e. (7766)8-(5544) 8
f. (9988)16–(AB)16
5. (1.5 points ) Write a program to ask the user to type the
height of a person in inches, and convert it to feet and inches.
You may assume the user only types numbers. Your program
should run like this:
Enter your height in inches: 71
Your height is 5 ' 11 ".
(0.5 point) Write the program
#python program
(0.5 point) Screenshot of the output
(0.5 point) Save the program as “height.py”
6. (1.5 points) Write a program to ask the user to input the
radius of a sphere, and then display the volume of the sphere.
You must determine the proper variable names. The formula to
compute the volume given the radius is provided:
, where is approximately 3.14159
You may assume the user only types numbers. Your program
should run like this:
Enter the radius of the sphere: 10
The volume of the sphere is 4188.786666666666
(0.5 point) Write the program
#python program
(0.5 point) Screenshot of the output
(0.5 point) Save the program as “sphere.py”
7. (2point, each for 0.2 point) The following truth table shows
various combinations of the values true and false connected by
a logical operator (and, or, not). Complete the table by circling
T or F to indicate whether the result of such a combination is
true or false.
Logical Expression
Result (circle T or F)
True and False
T
F
True and True
T
F
False and True
T
F
False and False
T
F
True or False
T
F
True or True
T
F
False or True
T
F
False or False
T
F
not True
T
F
not False
T
F
8. (2 points, each for 0.2 point) Assume the variables a = 2, b =
4, c = 6, x=0, y=2, and z=4. Circle T or F for each of the
following conditions to indicate whether its value is true or
false.
Expression (Condition)
Result (circle T or F)
a == 4 or b > 2
T
F
6 <=c and a > 3
T
F
1 != b and c != 3
T
F
a >= -1 or a<=b
T
F
not (a>2)
T
F
x or y
x and y
x or z
(x and y) or (y and z)
not y
9. (1 points, each for 0.2 point) Write logical expressions for
the following conditions:
a. x is not a negative number
b. x is a multiple of 7
c. x is greater than the sum of y and z
d. x is the greatest number among x, y, and z
e. x is less than 99 but greater than 49
10. (0.5 point, each 0.25 point) What would the following code
display?
a)
if 'z' < 'a':
print('z is less than a.')
else:
print('z is not less than a.')
(0.25 point) Screenshot of the output
b)
s1 = 'New York'
s2 = 'Boston'
if s1 > s2:
print(s2)
print(s1)
else:
print(s1)
print(s2)
(0.25 point) Screenshot of the output
11. (6 points, each 1 point) Draw flowcharts (only for
conditions with branches as shown on the left) and write code
fragments based on the flowcharts (not complete programs) to
complete the following task. Note: screenshots are not required
in this question.
a) if the variable x is greater than 100, assigns 20 to the
variable y and assigns 40 to the variable z
Flowchart
Code Fragments (python source code, not Screenshot)
b) if the variable a is less than 10, assigns 0 to the variable b ,
and assigns 1 to the variable c
Flowchart
Code Fragments (python source code, not Screenshot)
c) if the variable a is less than 10, assigns 0 to the variable b.
Otherwise, it should assign 99 to the variable b .
Flowchart
Code Fragments (python source code, not Screenshot)
d) if the variable speed is within the range of 24 to 56, displays
'Speed is normal'. Otherwise, display 'Speed is abnormal'
Flowchart
Code Fragments (python source code, not Screenshot)
e) Determine whether the variable points is outside the range of
9 to 51. If the variable’s value is outside this range, it should
display “Invalid points.” Otherwise, it should display “Valid
points.”
Flowchart
Code Fragments (python source code, not Screenshot)
f) If amount1 is greater than 10 and amount2 is less than 100,
display the greater of amount1 and amount2 .
Flowchart
Code Fragments (python source code, not Screenshot)
12. (2 points) Write a program that prompts the user for two
integers and then prints
a) The sum
b) The difference
c) The product
d) The average
e) The distance (absolute value of the difference)
f) The maximum (the larger of the two)
g) The minimum (the smaller of the two)
Hint: Python defines max and min functions that accept a
sequence of values, each separated with a comma.
(1 point) Write the program
#python program
(0.5 point) Screenshot of the output
(0.5 points) Save the program as “Calculation.py”
13. (1.5 points) Write a program that initializes a string variable
and prints the first three characters, followed by three periods,
and then the last three characters. For example, if the string is
initialized to ”Mississippi”, then print Mis...ppi.
(0.5 point) Write the program
#python program
(0.5 point) Screenshot of the output
(0.5 points) Save the program as “shorterString.py”
Total Grade (45 pts)
COSC 1436 Lab 4 Assignment
Name (First Last):
Data Representation II
1. (3 points, each for 0.5 point) Convert the following positive
binary numbers to their decimal number equivalents, showing
all steps.
a) 111111
b) 1110.11
c) 101111.101
d) 10111110.00001
e) 110011.011
2. (4 points, each for 0.5 point) Convert the following positive
decimal numbers to their binary equivalents showing all steps.
If needed, you can attach more papers.
a) 4.25
b) 0.9375
c) 254.75
d) 0.5625
e) 127.875
f) 104
g) 0.7578125
h) 3.125
3. (2 points) How many things can be represented with:
a. four bits
b. five bits
c. six bits
d. seven bits
4. (2 points) Using the following number line representation,
evaluate the expressions by showing all steps:
999
500 501 502 … 997 998
0 1 2 3 … 497 498 499
-500 -499 -498 ... -3 -2
-1 0 1 2 3 … 497 498 499
a. 498 + (-7)
b. -5 + (-2)
c. 5 – 8
d. -500+6
5. (3 points) Given a fixed-sized number scheme where k in the
formula for the ten's complement is 6 , answer the following
questions.
a. How many positive integers can be represented?
b. How many negative integers can be represented?
c. Draw the number line showing the three smallest and
largest positive numbers, the three smallest and largest negative
numbers, and zero.
6. (3 points) Using the number line in Qn5, find out the ten’s
complement representation of the following numbers. Show all
steps.
a. 35768
b. –35768
c. –444455
d. –123456
e. -23456
7. (5 points) Roulette Wheel Colors: On a roulette wheel, the
pockets are numbered from 0 to 36. The colors of the pockets
are as follows:
· Pocket 0 is green.
· For pockets 1 through 10, the odd-numbered pockets are red
and the even-numbered pockets are black.
· For pockets 11 through 18, the odd-numbered pockets are
black and the even-numbered pockets are red.
· For pockets 19 through 28, the odd-numbered pockets are red
and the even-numbered pockets are black.
· For pockets 29 through 36, the odd-numbered pockets are
black and the even-numbered pockets are red.
By referring to Figure 1, write a program that asks the user to
enter a pocket number and displays whether the pocket is green,
red, or black. The program should display an error message if
the user enters a number that is outside the range of 0 through
36. (Hint: use if-elif-else and nested if-else statements)
Before programming, we can have some fun first. An online
game is available at https://www.vegasslotsonline.com/table-
games/american-roulette/
Figure 1: Roulette Wheel Colors
· Source code of the project
#python program
· Screenshot of the output
· Save the program as “Roulette.py”
8. (1 point) What does the following loop print?
n = 1
while n < 100 :
n = 2 * n
print(n)
9. (1 point) Hand-trace the following code, showing the value of
n and the output.
n = 5
while n >= 0 :
n = n - 1
print(n)
10. (1 point) Hand-trace the following code, showing the value
of n and the output.
n = 1
while n <= 3 :
print(n)
n = n + 1
11. (1 point) Hand-trace the following code, assuming that a is
2 and n is 4. Then explain what the code does for arbitrary
values of a and n.
r = 1
i = 1
while i <= n :
r = r * a
i = i + 1
12. (1 point) Hand-trace the following code. What error do you
observe?
n = 1
while n != 50 :
print(n)
n = n + 10
13. (2 point) What is wrong with the following loop for finding
the smallest input value?
smallest = 0
inputStr = input("Enter a value: ")
while inputStr != "" :
value = int(inputStr)
if value < smallest :
smallest = value
inputStr = input("Enter a value: ")
14. (1 point) How many numbers does this loop print?
for n in range(10, -1, -1) :
print(n)
15. (2 points) Write a for loop that prints all even numbers
between 10 and 20 (inclusive).
16. (5 points) Write while loops that prints
a) All squares less than n. For example, if n is 100, print 0 1 4 9
16 25 36 49 64 81.
b) All positive numbers that are divisible by 10 and less than n.
For example, if n is 100, print 10 20 30 40 50 60 70 80 90
c) All powers of two less than n. For example, if n is 100, print
1 2 4 8 16 32 64.
· Source code of the project
#python program
· Screenshot of the output
· Save the program as “Qn16.py”
17. (3 points) Number guessing game – First, we use randint to
generate a random number N between 1 and 100:
from random import randint
N = randint(1, 100)
Complete the program. The program shall ask the user to guess
what N is. Every time the user makes a guess, the program shall
tell the user whether the guessed number is greater than, equal
to, or less than N. If the guessed number equals to N, the
program should terminate. You may assume that the user only
types integers.
· Source code of the project
#python program
· Screenshot of the output
· Save the program as “Qn17.py”
18. (5 points) Write loops that computes
a) The sum of all even numbers between 2 and 100 (inclusive).
b) The sum of all squares between 1 and 100 (inclusive).
c) The sum of all odd numbers between a and b (inclusive).
d) The sum of all odd digits of n. (For example, if n is 32677,
the sum would be 3 + 7 + 7 = 17.)
· Source code of the project
#python program
· Screenshot of the output
· Save the program as “Qn18.py”
COSC 1436 Final Exam Review Exercises
Q1: Which of the following is a relational operator?
A. = B. == C. and D. or
Q2: Which print statement displays the value of s without
starting a new line?
A. print(end="s")
B. print(s)
C. print("s")
D. print(s, end="")
Q3: What is the output of the following code snippet?
i = 1
while i < 10 :
print(i, end = " ")
i = i + 2
if i == 5 :
i = 9
A. 1 3 5 B. 1 3 9 C. 1 3 5 7
9 D. 1 3 5 9
Q4: What is the minimum number of bits needed to represent 16
things?
A. 2 B. 3 C. 4 D. 8
Q5: What causes numeric overflow?
A. using fixed-sized numbers in a floating-point calculation
B. a calculation producing an invalid result
C. a calculation producing a value that won't fit into the
allotted space
D. using a radix point instead of a decimal point
E. using a radix point in a fixed-sized number calculation
Q6: A ___________________________ is a sequence of
instructions with a name.
A. variable B. argument C. parameter
D. function
Q7: True or False:
a) Audio data is often represented on a computer by sampling
the continuous signal that represents a sound wave.
____________
b) An AND gate and an OR gate produce opposite output.
____________
c) Vector graphics represent images in terms of lines and
geometric shapes. ____________
d) An absolute path begins at the current working directory.
____________
e) The IP address 121.122.500.124 is valid. ____________
f) RAM is non-volatile and ROM is volatile. ____________
Q8: The gate that produces the opposite results of an AND gate
is called a(n) _______________ gate.
Q9: A(n) _______________ circuit has multiple gates
embedded into it.
Q10: IPv4 IP addresses are ___ (2, 8 ,32, or128) bits.
Q11: Convert (345.28125)10 to binary number. Show all
steps.
Q12: What is the function of the ALU?
Q13: What is difference between Domain name and IP address?
Q14: Give the Boolean expression and draw the truth table for
the following circuit
Q15: Write loops that computes
a) The sum of all even numbers between 2 and 100 (inclusive).
b) The sum of all squares between 1 and 100 (inclusive).
c) The sum of all odd numbers between a and b (inclusive).
d) The sum of all odd digits of n. (For example, if n is 32677,
the sum would be 3 + 7 + 7 = 17.)
Total Grade (30 pts)COSC 1436 Weeks 5-6  Lab Assignment -3Na

More Related Content

Similar to Total Grade (30 pts)COSC 1436 Weeks 5-6 Lab Assignment -3Na

Module 1 number systems and code1
Module 1  number systems and code1Module 1  number systems and code1
Module 1 number systems and code1Deepak John
 
Functions Practice Sheet.docx
Functions Practice Sheet.docxFunctions Practice Sheet.docx
Functions Practice Sheet.docxSwatiMishra364461
 
Data representation moris mano ch 03
Data representation   moris mano ch  03Data representation   moris mano ch  03
Data representation moris mano ch 03thearticlenow
 
Python programming workshop session 2
Python programming workshop session 2Python programming workshop session 2
Python programming workshop session 2Abdul Haseeb
 
Number system computer fundamental
 Number  system computer fundamental  Number  system computer fundamental
Number system computer fundamental Aman anand kumar
 
Sample Exam Questions on Python for revision
Sample Exam Questions on Python for revisionSample Exam Questions on Python for revision
Sample Exam Questions on Python for revisionafsheenfaiq2
 
Chapter_1_Digital_Systems_and_Binary_Numbers2.ppt
Chapter_1_Digital_Systems_and_Binary_Numbers2.pptChapter_1_Digital_Systems_and_Binary_Numbers2.ppt
Chapter_1_Digital_Systems_and_Binary_Numbers2.pptDavid Louie Bedia
 
Video lectures
Video lecturesVideo lectures
Video lecturesEdhole.com
 
Qust & ans inc
Qust & ans incQust & ans inc
Qust & ans incnayakq
 
Answers To Selected Exercises For Fortran 90 95 For Scientists And Engineers
Answers To Selected Exercises For Fortran 90 95 For Scientists And EngineersAnswers To Selected Exercises For Fortran 90 95 For Scientists And Engineers
Answers To Selected Exercises For Fortran 90 95 For Scientists And EngineersSheila Sinclair
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAAiman Hud
 

Similar to Total Grade (30 pts)COSC 1436 Weeks 5-6 Lab Assignment -3Na (20)

Module 1 number systems and code1
Module 1  number systems and code1Module 1  number systems and code1
Module 1 number systems and code1
 
Functions Practice Sheet.docx
Functions Practice Sheet.docxFunctions Practice Sheet.docx
Functions Practice Sheet.docx
 
Datarepresentation2
Datarepresentation2Datarepresentation2
Datarepresentation2
 
Data representation moris mano ch 03
Data representation   moris mano ch  03Data representation   moris mano ch  03
Data representation moris mano ch 03
 
Python programming workshop session 2
Python programming workshop session 2Python programming workshop session 2
Python programming workshop session 2
 
algorithm
algorithmalgorithm
algorithm
 
DATA REPRESENTATION
DATA  REPRESENTATIONDATA  REPRESENTATION
DATA REPRESENTATION
 
Number system computer fundamental
 Number  system computer fundamental  Number  system computer fundamental
Number system computer fundamental
 
Sample Exam Questions on Python for revision
Sample Exam Questions on Python for revisionSample Exam Questions on Python for revision
Sample Exam Questions on Python for revision
 
Number system
Number systemNumber system
Number system
 
Chapter_1_Digital_Systems_and_Binary_Numbers2.ppt
Chapter_1_Digital_Systems_and_Binary_Numbers2.pptChapter_1_Digital_Systems_and_Binary_Numbers2.ppt
Chapter_1_Digital_Systems_and_Binary_Numbers2.ppt
 
Video lectures
Video lecturesVideo lectures
Video lectures
 
Mba ebooks
Mba ebooksMba ebooks
Mba ebooks
 
Okkkkk
OkkkkkOkkkkk
Okkkkk
 
Qust & ans inc
Qust & ans incQust & ans inc
Qust & ans inc
 
Answers To Selected Exercises For Fortran 90 95 For Scientists And Engineers
Answers To Selected Exercises For Fortran 90 95 For Scientists And EngineersAnswers To Selected Exercises For Fortran 90 95 For Scientists And Engineers
Answers To Selected Exercises For Fortran 90 95 For Scientists And Engineers
 
Introduction to python programming
Introduction to python programmingIntroduction to python programming
Introduction to python programming
 
Number_Systems (2).ppt
Number_Systems (2).pptNumber_Systems (2).ppt
Number_Systems (2).ppt
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
1.2 matlab numerical data
1.2  matlab numerical data1.2  matlab numerical data
1.2 matlab numerical data
 

More from curranalmeta

1 PageAPAsources2Today, many more organizations leverage worl.docx
1 PageAPAsources2Today, many more organizations leverage worl.docx1 PageAPAsources2Today, many more organizations leverage worl.docx
1 PageAPAsources2Today, many more organizations leverage worl.docxcurranalmeta
 
1) A major corporation agrees to sponsor an internal study on sexual.docx
1) A major corporation agrees to sponsor an internal study on sexual.docx1) A major corporation agrees to sponsor an internal study on sexual.docx
1) A major corporation agrees to sponsor an internal study on sexual.docxcurranalmeta
 
1  Identify a large racial minority group in U.S. history What has.docx
1  Identify a large racial minority group in U.S. history What has.docx1  Identify a large racial minority group in U.S. history What has.docx
1  Identify a large racial minority group in U.S. history What has.docxcurranalmeta
 
1   With any new technology, it takes time for ethical, social, and.docx
1   With any new technology, it takes time for ethical, social, and.docx1   With any new technology, it takes time for ethical, social, and.docx
1   With any new technology, it takes time for ethical, social, and.docxcurranalmeta
 
1 paragraphNo plagiarism 2 Sources Grading RubricBasic r.docx
1 paragraphNo plagiarism 2 Sources Grading RubricBasic r.docx1 paragraphNo plagiarism 2 Sources Grading RubricBasic r.docx
1 paragraphNo plagiarism 2 Sources Grading RubricBasic r.docxcurranalmeta
 
1 PageDiscuss capitation payment methodologies between payers .docx
1 PageDiscuss capitation payment methodologies between payers .docx1 PageDiscuss capitation payment methodologies between payers .docx
1 PageDiscuss capitation payment methodologies between payers .docxcurranalmeta
 
1) Anytime an owner removes any asset for personal use it is recor.docx
1) Anytime an owner removes any asset for personal use it is recor.docx1) Anytime an owner removes any asset for personal use it is recor.docx
1) Anytime an owner removes any asset for personal use it is recor.docxcurranalmeta
 
1 Page Length In this lab, you will observe the time progressi.docx
1 Page Length In this lab, you will observe the time progressi.docx1 Page Length In this lab, you will observe the time progressi.docx
1 Page Length In this lab, you will observe the time progressi.docxcurranalmeta
 
1 page orignal answer needed·A number of organizations exist.docx
1 page orignal answer needed·A number of organizations exist.docx1 page orignal answer needed·A number of organizations exist.docx
1 page orignal answer needed·A number of organizations exist.docxcurranalmeta
 
1) discuss 2 major political implications of the cold war in europe..docx
1) discuss 2 major political implications of the cold war in europe..docx1) discuss 2 major political implications of the cold war in europe..docx
1) discuss 2 major political implications of the cold war in europe..docxcurranalmeta
 
1) Discuss the benefits of using comparative analysis of governments.docx
1) Discuss the benefits of using comparative analysis of governments.docx1) Discuss the benefits of using comparative analysis of governments.docx
1) Discuss the benefits of using comparative analysis of governments.docxcurranalmeta
 
1) Discuss essential and non-essential amino acids. Explain why prot.docx
1) Discuss essential and non-essential amino acids. Explain why prot.docx1) Discuss essential and non-essential amino acids. Explain why prot.docx
1) Discuss essential and non-essential amino acids. Explain why prot.docxcurranalmeta
 
1 Team Assignment (Will let you know which portion to complete).docx
1 Team Assignment (Will let you know which portion to complete).docx1 Team Assignment (Will let you know which portion to complete).docx
1 Team Assignment (Will let you know which portion to complete).docxcurranalmeta
 
1) Body of paper must be 4-5 pages 12 pitch Times Roman Double.docx
1) Body of paper must be 4-5 pages  12 pitch  Times Roman  Double.docx1) Body of paper must be 4-5 pages  12 pitch  Times Roman  Double.docx
1) Body of paper must be 4-5 pages 12 pitch Times Roman Double.docxcurranalmeta
 
1) CBS and the NYT conducted a national poll of 1048 randomly select.docx
1) CBS and the NYT conducted a national poll of 1048 randomly select.docx1) CBS and the NYT conducted a national poll of 1048 randomly select.docx
1) CBS and the NYT conducted a national poll of 1048 randomly select.docxcurranalmeta
 
1 page each question! double spaced Times New Roman 12 font CITE.docx
1 page each question! double spaced Times New Roman 12 font CITE.docx1 page each question! double spaced Times New Roman 12 font CITE.docx
1 page each question! double spaced Times New Roman 12 font CITE.docxcurranalmeta
 
1) Backers of a balanced-budget amendment to the Constitution might .docx
1) Backers of a balanced-budget amendment to the Constitution might .docx1) Backers of a balanced-budget amendment to the Constitution might .docx
1) Backers of a balanced-budget amendment to the Constitution might .docxcurranalmeta
 
Trust in Team DynamicsTrust is a key aspect in team dynami
Trust in Team DynamicsTrust is a key aspect in team dynamiTrust in Team DynamicsTrust is a key aspect in team dynami
Trust in Team DynamicsTrust is a key aspect in team dynamicurranalmeta
 
Turnitin Plagiarism checker enabled.What is the definition of
Turnitin Plagiarism checker enabled.What is the definition of Turnitin Plagiarism checker enabled.What is the definition of
Turnitin Plagiarism checker enabled.What is the definition of curranalmeta
 
Try to go to a museum that you have not been to before if your ass
Try to go to a museum that you have not been to before if your assTry to go to a museum that you have not been to before if your ass
Try to go to a museum that you have not been to before if your asscurranalmeta
 

More from curranalmeta (20)

1 PageAPAsources2Today, many more organizations leverage worl.docx
1 PageAPAsources2Today, many more organizations leverage worl.docx1 PageAPAsources2Today, many more organizations leverage worl.docx
1 PageAPAsources2Today, many more organizations leverage worl.docx
 
1) A major corporation agrees to sponsor an internal study on sexual.docx
1) A major corporation agrees to sponsor an internal study on sexual.docx1) A major corporation agrees to sponsor an internal study on sexual.docx
1) A major corporation agrees to sponsor an internal study on sexual.docx
 
1  Identify a large racial minority group in U.S. history What has.docx
1  Identify a large racial minority group in U.S. history What has.docx1  Identify a large racial minority group in U.S. history What has.docx
1  Identify a large racial minority group in U.S. history What has.docx
 
1   With any new technology, it takes time for ethical, social, and.docx
1   With any new technology, it takes time for ethical, social, and.docx1   With any new technology, it takes time for ethical, social, and.docx
1   With any new technology, it takes time for ethical, social, and.docx
 
1 paragraphNo plagiarism 2 Sources Grading RubricBasic r.docx
1 paragraphNo plagiarism 2 Sources Grading RubricBasic r.docx1 paragraphNo plagiarism 2 Sources Grading RubricBasic r.docx
1 paragraphNo plagiarism 2 Sources Grading RubricBasic r.docx
 
1 PageDiscuss capitation payment methodologies between payers .docx
1 PageDiscuss capitation payment methodologies between payers .docx1 PageDiscuss capitation payment methodologies between payers .docx
1 PageDiscuss capitation payment methodologies between payers .docx
 
1) Anytime an owner removes any asset for personal use it is recor.docx
1) Anytime an owner removes any asset for personal use it is recor.docx1) Anytime an owner removes any asset for personal use it is recor.docx
1) Anytime an owner removes any asset for personal use it is recor.docx
 
1 Page Length In this lab, you will observe the time progressi.docx
1 Page Length In this lab, you will observe the time progressi.docx1 Page Length In this lab, you will observe the time progressi.docx
1 Page Length In this lab, you will observe the time progressi.docx
 
1 page orignal answer needed·A number of organizations exist.docx
1 page orignal answer needed·A number of organizations exist.docx1 page orignal answer needed·A number of organizations exist.docx
1 page orignal answer needed·A number of organizations exist.docx
 
1) discuss 2 major political implications of the cold war in europe..docx
1) discuss 2 major political implications of the cold war in europe..docx1) discuss 2 major political implications of the cold war in europe..docx
1) discuss 2 major political implications of the cold war in europe..docx
 
1) Discuss the benefits of using comparative analysis of governments.docx
1) Discuss the benefits of using comparative analysis of governments.docx1) Discuss the benefits of using comparative analysis of governments.docx
1) Discuss the benefits of using comparative analysis of governments.docx
 
1) Discuss essential and non-essential amino acids. Explain why prot.docx
1) Discuss essential and non-essential amino acids. Explain why prot.docx1) Discuss essential and non-essential amino acids. Explain why prot.docx
1) Discuss essential and non-essential amino acids. Explain why prot.docx
 
1 Team Assignment (Will let you know which portion to complete).docx
1 Team Assignment (Will let you know which portion to complete).docx1 Team Assignment (Will let you know which portion to complete).docx
1 Team Assignment (Will let you know which portion to complete).docx
 
1) Body of paper must be 4-5 pages 12 pitch Times Roman Double.docx
1) Body of paper must be 4-5 pages  12 pitch  Times Roman  Double.docx1) Body of paper must be 4-5 pages  12 pitch  Times Roman  Double.docx
1) Body of paper must be 4-5 pages 12 pitch Times Roman Double.docx
 
1) CBS and the NYT conducted a national poll of 1048 randomly select.docx
1) CBS and the NYT conducted a national poll of 1048 randomly select.docx1) CBS and the NYT conducted a national poll of 1048 randomly select.docx
1) CBS and the NYT conducted a national poll of 1048 randomly select.docx
 
1 page each question! double spaced Times New Roman 12 font CITE.docx
1 page each question! double spaced Times New Roman 12 font CITE.docx1 page each question! double spaced Times New Roman 12 font CITE.docx
1 page each question! double spaced Times New Roman 12 font CITE.docx
 
1) Backers of a balanced-budget amendment to the Constitution might .docx
1) Backers of a balanced-budget amendment to the Constitution might .docx1) Backers of a balanced-budget amendment to the Constitution might .docx
1) Backers of a balanced-budget amendment to the Constitution might .docx
 
Trust in Team DynamicsTrust is a key aspect in team dynami
Trust in Team DynamicsTrust is a key aspect in team dynamiTrust in Team DynamicsTrust is a key aspect in team dynami
Trust in Team DynamicsTrust is a key aspect in team dynami
 
Turnitin Plagiarism checker enabled.What is the definition of
Turnitin Plagiarism checker enabled.What is the definition of Turnitin Plagiarism checker enabled.What is the definition of
Turnitin Plagiarism checker enabled.What is the definition of
 
Try to go to a museum that you have not been to before if your ass
Try to go to a museum that you have not been to before if your assTry to go to a museum that you have not been to before if your ass
Try to go to a museum that you have not been to before if your ass
 

Recently uploaded

FILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinoFILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinojohnmickonozaleda
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)cama23
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptxiammrhaywood
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfErwinPantujan2
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Seán Kennedy
 

Recently uploaded (20)

FILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinoFILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipino
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...
 

Total Grade (30 pts)COSC 1436 Weeks 5-6 Lab Assignment -3Na

  • 1. Total Grade (30 pts) COSC 1436 Weeks 5-6 Lab Assignment -3 Name (First Last): Data Conversions and Control structures I 1. (3 points, each for 0.5 point ) Convert each of following numbers to Octal numbers, showing all steps. a. (111110110)2 b. (1100010)2 c. (2001)10 d. (1492)10 e. (A9)16 f. (5FF71 )16 2. (3 points, each for 0.5 point ) Convert each of following numbers to Binary numbers, showing all steps. a. (572) 8 b. (1604) 8 c. (1066)10 d. (99)10 e. (80E)16 f. (135AB)16
  • 2. 3. (3 points, each for 0.5 point ) Convert each of following numbers to Hexadecimal numbers, showing all steps. a. (1111 0111)2 b. (1010 1010 1010)2 c. (777) 8 d. (443) 8 e. (998)10 f. (1066)10 4. (3 points, each for 0.5 point ) Evaluate the following expressions. For each expression, keep the same number system as it is. Do not convert the number systems. E.g. if the
  • 3. expression is written using hexadecimal number system, your answer should also be written in hexadecimal number system. a. (1110 1111)2+(1011 1101)2 b. (11000001)2-(100010)2 c. (202) 8+( 667) 8 d. (1066)16+ (ABCD)16 e. (7766)8-(5544) 8 f. (9988)16–(AB)16 5. (1.5 points ) Write a program to ask the user to type the height of a person in inches, and convert it to feet and inches. You may assume the user only types numbers. Your program should run like this: Enter your height in inches: 71 Your height is 5 ' 11 ". (0.5 point) Write the program #python program
  • 4. (0.5 point) Screenshot of the output (0.5 point) Save the program as “height.py” 6. (1.5 points) Write a program to ask the user to input the radius of a sphere, and then display the volume of the sphere. You must determine the proper variable names. The formula to compute the volume given the radius is provided: , where is approximately 3.14159 You may assume the user only types numbers. Your program should run like this: Enter the radius of the sphere: 10 The volume of the sphere is 4188.786666666666 (0.5 point) Write the program #python program (0.5 point) Screenshot of the output (0.5 point) Save the program as “sphere.py” 7. (2point, each for 0.2 point) The following truth table shows various combinations of the values true and false connected by a logical operator (and, or, not). Complete the table by circling T or F to indicate whether the result of such a combination is true or false.
  • 5. Logical Expression Result (circle T or F) True and False T F True and True T F False and True T F False and False T F True or False T F True or True T F False or True T F False or False T F not True T F not False T F 8. (2 points, each for 0.2 point) Assume the variables a = 2, b = 4, c = 6, x=0, y=2, and z=4. Circle T or F for each of the following conditions to indicate whether its value is true or
  • 6. false. Expression (Condition) Result (circle T or F) a == 4 or b > 2 T F 6 <=c and a > 3 T F 1 != b and c != 3 T F a >= -1 or a<=b T F not (a>2) T F x or y x and y x or z (x and y) or (y and z) not y 9. (1 points, each for 0.2 point) Write logical expressions for the following conditions: a. x is not a negative number b. x is a multiple of 7 c. x is greater than the sum of y and z d. x is the greatest number among x, y, and z
  • 7. e. x is less than 99 but greater than 49 10. (0.5 point, each 0.25 point) What would the following code display? a) if 'z' < 'a': print('z is less than a.') else: print('z is not less than a.') (0.25 point) Screenshot of the output b) s1 = 'New York' s2 = 'Boston' if s1 > s2: print(s2) print(s1) else: print(s1) print(s2)
  • 8. (0.25 point) Screenshot of the output 11. (6 points, each 1 point) Draw flowcharts (only for conditions with branches as shown on the left) and write code fragments based on the flowcharts (not complete programs) to complete the following task. Note: screenshots are not required in this question. a) if the variable x is greater than 100, assigns 20 to the variable y and assigns 40 to the variable z Flowchart Code Fragments (python source code, not Screenshot) b) if the variable a is less than 10, assigns 0 to the variable b , and assigns 1 to the variable c Flowchart Code Fragments (python source code, not Screenshot)
  • 9. c) if the variable a is less than 10, assigns 0 to the variable b. Otherwise, it should assign 99 to the variable b . Flowchart Code Fragments (python source code, not Screenshot) d) if the variable speed is within the range of 24 to 56, displays 'Speed is normal'. Otherwise, display 'Speed is abnormal' Flowchart Code Fragments (python source code, not Screenshot) e) Determine whether the variable points is outside the range of 9 to 51. If the variable’s value is outside this range, it should display “Invalid points.” Otherwise, it should display “Valid points.” Flowchart
  • 10. Code Fragments (python source code, not Screenshot) f) If amount1 is greater than 10 and amount2 is less than 100, display the greater of amount1 and amount2 . Flowchart Code Fragments (python source code, not Screenshot) 12. (2 points) Write a program that prompts the user for two integers and then prints a) The sum b) The difference c) The product d) The average e) The distance (absolute value of the difference) f) The maximum (the larger of the two) g) The minimum (the smaller of the two) Hint: Python defines max and min functions that accept a sequence of values, each separated with a comma.
  • 11. (1 point) Write the program #python program (0.5 point) Screenshot of the output (0.5 points) Save the program as “Calculation.py” 13. (1.5 points) Write a program that initializes a string variable and prints the first three characters, followed by three periods, and then the last three characters. For example, if the string is initialized to ”Mississippi”, then print Mis...ppi. (0.5 point) Write the program #python program (0.5 point) Screenshot of the output (0.5 points) Save the program as “shorterString.py”
  • 12. Total Grade (45 pts) COSC 1436 Lab 4 Assignment Name (First Last): Data Representation II 1. (3 points, each for 0.5 point) Convert the following positive binary numbers to their decimal number equivalents, showing all steps. a) 111111 b) 1110.11 c) 101111.101 d) 10111110.00001 e) 110011.011 2. (4 points, each for 0.5 point) Convert the following positive decimal numbers to their binary equivalents showing all steps. If needed, you can attach more papers. a) 4.25 b) 0.9375 c) 254.75 d) 0.5625 e) 127.875 f) 104 g) 0.7578125 h) 3.125
  • 13. 3. (2 points) How many things can be represented with: a. four bits b. five bits c. six bits d. seven bits 4. (2 points) Using the following number line representation, evaluate the expressions by showing all steps: 999 500 501 502 … 997 998
  • 14. 0 1 2 3 … 497 498 499 -500 -499 -498 ... -3 -2 -1 0 1 2 3 … 497 498 499 a. 498 + (-7) b. -5 + (-2) c. 5 – 8 d. -500+6 5. (3 points) Given a fixed-sized number scheme where k in the formula for the ten's complement is 6 , answer the following questions. a. How many positive integers can be represented? b. How many negative integers can be represented? c. Draw the number line showing the three smallest and largest positive numbers, the three smallest and largest negative numbers, and zero.
  • 15. 6. (3 points) Using the number line in Qn5, find out the ten’s complement representation of the following numbers. Show all steps. a. 35768 b. –35768 c. –444455 d. –123456 e. -23456 7. (5 points) Roulette Wheel Colors: On a roulette wheel, the pockets are numbered from 0 to 36. The colors of the pockets are as follows: · Pocket 0 is green. · For pockets 1 through 10, the odd-numbered pockets are red and the even-numbered pockets are black. · For pockets 11 through 18, the odd-numbered pockets are black and the even-numbered pockets are red. · For pockets 19 through 28, the odd-numbered pockets are red and the even-numbered pockets are black. · For pockets 29 through 36, the odd-numbered pockets are black and the even-numbered pockets are red. By referring to Figure 1, write a program that asks the user to
  • 16. enter a pocket number and displays whether the pocket is green, red, or black. The program should display an error message if the user enters a number that is outside the range of 0 through 36. (Hint: use if-elif-else and nested if-else statements) Before programming, we can have some fun first. An online game is available at https://www.vegasslotsonline.com/table- games/american-roulette/ Figure 1: Roulette Wheel Colors · Source code of the project #python program · Screenshot of the output · Save the program as “Roulette.py” 8. (1 point) What does the following loop print? n = 1 while n < 100 : n = 2 * n print(n)
  • 17. 9. (1 point) Hand-trace the following code, showing the value of n and the output. n = 5 while n >= 0 : n = n - 1 print(n) 10. (1 point) Hand-trace the following code, showing the value of n and the output. n = 1 while n <= 3 : print(n) n = n + 1 11. (1 point) Hand-trace the following code, assuming that a is 2 and n is 4. Then explain what the code does for arbitrary values of a and n. r = 1 i = 1 while i <= n : r = r * a i = i + 1 12. (1 point) Hand-trace the following code. What error do you observe? n = 1
  • 18. while n != 50 : print(n) n = n + 10 13. (2 point) What is wrong with the following loop for finding the smallest input value? smallest = 0 inputStr = input("Enter a value: ") while inputStr != "" : value = int(inputStr) if value < smallest : smallest = value inputStr = input("Enter a value: ") 14. (1 point) How many numbers does this loop print? for n in range(10, -1, -1) : print(n) 15. (2 points) Write a for loop that prints all even numbers between 10 and 20 (inclusive).
  • 19. 16. (5 points) Write while loops that prints a) All squares less than n. For example, if n is 100, print 0 1 4 9 16 25 36 49 64 81. b) All positive numbers that are divisible by 10 and less than n. For example, if n is 100, print 10 20 30 40 50 60 70 80 90 c) All powers of two less than n. For example, if n is 100, print 1 2 4 8 16 32 64. · Source code of the project #python program · Screenshot of the output · Save the program as “Qn16.py” 17. (3 points) Number guessing game – First, we use randint to generate a random number N between 1 and 100: from random import randint N = randint(1, 100) Complete the program. The program shall ask the user to guess what N is. Every time the user makes a guess, the program shall tell the user whether the guessed number is greater than, equal to, or less than N. If the guessed number equals to N, the program should terminate. You may assume that the user only types integers.
  • 20. · Source code of the project #python program · Screenshot of the output · Save the program as “Qn17.py” 18. (5 points) Write loops that computes a) The sum of all even numbers between 2 and 100 (inclusive). b) The sum of all squares between 1 and 100 (inclusive). c) The sum of all odd numbers between a and b (inclusive). d) The sum of all odd digits of n. (For example, if n is 32677, the sum would be 3 + 7 + 7 = 17.) · Source code of the project #python program · Screenshot of the output · Save the program as “Qn18.py” COSC 1436 Final Exam Review Exercises
  • 21. Q1: Which of the following is a relational operator? A. = B. == C. and D. or Q2: Which print statement displays the value of s without starting a new line? A. print(end="s") B. print(s) C. print("s") D. print(s, end="") Q3: What is the output of the following code snippet? i = 1 while i < 10 : print(i, end = " ") i = i + 2 if i == 5 : i = 9 A. 1 3 5 B. 1 3 9 C. 1 3 5 7 9 D. 1 3 5 9 Q4: What is the minimum number of bits needed to represent 16 things? A. 2 B. 3 C. 4 D. 8 Q5: What causes numeric overflow? A. using fixed-sized numbers in a floating-point calculation B. a calculation producing an invalid result C. a calculation producing a value that won't fit into the allotted space
  • 22. D. using a radix point instead of a decimal point E. using a radix point in a fixed-sized number calculation Q6: A ___________________________ is a sequence of instructions with a name. A. variable B. argument C. parameter D. function Q7: True or False: a) Audio data is often represented on a computer by sampling the continuous signal that represents a sound wave. ____________ b) An AND gate and an OR gate produce opposite output. ____________ c) Vector graphics represent images in terms of lines and geometric shapes. ____________ d) An absolute path begins at the current working directory. ____________ e) The IP address 121.122.500.124 is valid. ____________ f) RAM is non-volatile and ROM is volatile. ____________ Q8: The gate that produces the opposite results of an AND gate is called a(n) _______________ gate. Q9: A(n) _______________ circuit has multiple gates embedded into it.
  • 23. Q10: IPv4 IP addresses are ___ (2, 8 ,32, or128) bits. Q11: Convert (345.28125)10 to binary number. Show all steps. Q12: What is the function of the ALU? Q13: What is difference between Domain name and IP address? Q14: Give the Boolean expression and draw the truth table for the following circuit Q15: Write loops that computes a) The sum of all even numbers between 2 and 100 (inclusive). b) The sum of all squares between 1 and 100 (inclusive). c) The sum of all odd numbers between a and b (inclusive). d) The sum of all odd digits of n. (For example, if n is 32677, the sum would be 3 + 7 + 7 = 17.)