Note that there will be no if-else instruction questions on this first exam since we did not write any programs to do this as of yet.
1. Convert the binary number 101101 to base 10.
2. Convert the base 8 number 2451 to base 10
3. Convert the base 16 number 3C5 to base 10.
4. Convert the binary number 1011101011101 to base 16.
5. Convert the binary number 1011101011 to base 8.
6. Add the two binary numbers 11101011 and 10111101 giving the answer in binary.
7. How many bits in a byte? How many different objects can a single byte represent?
8. What is ASCII? What do the letters stand for?
9. What is a text file?
10. What happens when each of the following DOS command are executed.
- cd ..
- cd harry
- type file.txt
- type file.txt > data.txt
- type file.txt >> data.txt
- mkdir dataset
- more file.txt <– I did not teach you this command in class.Look it up in the DOS command tutorial.
- hd file.txt
10. When you list the directory what are two attributes that are give with the file names?
11. What does the following program print.
x=2 y=7 z=3 m=x+3*(y-z); print "The answer is",m;
12. What is the difference between print” hello “; and print ” hello\n”; ?
13. What is the output of the following
import math a=3 b=4 c = math.sqrt(a**2+b**2) print c
14. What is the difference between syntax and semantics of a Python instruction?
15. Write a program that prints the volume of a box with dimensions w,h,l. Read in the three variables.
16. Explain in words what the command c= input(“Give me a number:”) does.
17. The area of a circle is pi*r squared. Write a program that returns this area given the radius r is read in with an input() command