Convert decimal 121 to binary:
Solution Method 1:
128 fits into 121? NO b7 = 0
64 fits into 121? YES b6 = 1
121 - 64 = 57
Continue with 57 
32 fits into 57? YES b5 = 1
57 - 32 = 25
Continue with 25:
16 fits into 25? YES b4 = 1
25 - 16 = 9
Continue with 9
8 fits into 9? YES b3 = 1
9 - 8 = 1
Continue with 1
4 fits into  1?  NO b2 = 0
2 fits into 1? NO b1 = 0
1 fits into 1? YES b0 = 1
Final answer: Decimal number 121 in binary is 0111 1001
Method 2 using Integer Division and Remainder:
121 / 2 = 60 remainder 1 b0 = 1
60 / 2 = 30 remainder 0 b1 = 0
30 / 2 = 15 remainder 0 b2 = 0
15 / 2 = 7 remainder 1 b3 = 1
7 / 2 = 3 remainder 1 b4 = 1
3 / 2 = 1 remainder 1 b5 = 1
1 / 2 = 0 remainder 1 b6 = 1
As soon as we got 0 the process is stopped and the rest of the bits are 0:b7 =0
Final Answer: Decimal number 121 in binary system is:  0111 1001

Homework 1 - Due Day Monday Sept 14
Hide a text message inside the binary sequence of your choice. Limit 
the length of the message to 3-4 characters. Write a binary sequence with 
hidden message on a separate page (written or printed) and bring it to 
class on Monday. On Monday, 
you will exchange hidden messages with the student sitting next to you and 
unhide the messages.
.   

Week 3:
Mini Quiz 2 Friday Sept 18 Structure and Material:
- Question 1: Encode short word (2-3 letters) into binary. Explain ONE letter in detail. 
- Question 2: Decode short binary sequence into sequence of characters (3-4 letters). Explain ONE BYTE in detail.
 
- CANNOT use: computers, calculators, cell phones, textbooks, notes (see below what is allowed).
- The only allowed open material:
-  ONE PAGE (2 sides) of your own written or
ptinted notes 
- ASCII TABLE (will be provided). 
 
- Example 1: Convert Go! to binary
 Solution: Go! in ASCII is: 71 111 33
 71 to binary:
 71/2  = 35 b0 = 1
 35/2 = 17 b1 = 1
 17/2 = 8 b2 = 1
 8/2 = 4 b3 = 0
 4/2 = 2 b4 = 0
 2/2 = 1 b5 = 0
 1/2 = 0 b6 = 1
 71 in binary: 0100 0111
 111 in binary: 0110 1111
 33 in binary: 0010 0001
 - Final answer: Go! in binary: 01000111  01101111 00100001
 
- Example 2: Decode: 01101101 01000101 00110010
 Solution: converting each BYTE to decimal
 0110 1101  adding powers of 2 that are ON: 64 + 32 + 8 + 4 + 1 = 109
 0100 0101 is 69
 0011 0010 is 50
 Original message in ASCII 109 69 50Final answer: decoded word: mE2  
 
 
 
Week 4:
Input in Python:
 - For integers use: int(input("user prompt 
")) 
- For floats use: float(input("user prompt ")) 
- For strings 
use: input("user prompt ") and when inputing the string you must enclose 
it in double or single quotes 
- For formatted output use function 
format. - For example, to print only 2 decimal digits of 
the number 1232.566777 use the following statement: 
print(format(1232.566777, '.2f'))
- For example, to print 
only 4 decimal digits of the number 1232.566777 use the following 
statement: print(format(1232.566777, '.4f'))
 
TEST 1 on Monday, Sept 27
 
TEST 1 Structure
- Duration: 50 minutes
- Place: In class
- Material: can you use computer
- Part I: 1 question to write the output of the program that is given 
to you and explain 
your answer
- Part II: 1 question to write short program. 
Program is similar to the programs that 
you wrote  during LAB sessions   
Test 2 Date: Friday, Oct 23
 TEST 2 Preparation 
 TEST 2 Preparation Part 2 - Lecture Practice Oct 21
 Mini Quiz 5
Homework 1: Due Day Friday, Oct 16:
There is a treasure chest with 1 million dollars. The 
chest has a 5-digit combination lock that opens under the 
following conditions: the first digit should be equal to the 
fifth digit, the second digit should be odd, and the product 
of the third and forth digits should be divisible by 7. Write a 
function unlock that has one parameter, 5 
-digit integer. The function returns True if the number unlock the 
treasure chest and False otherwise. Write a program 
that reads TWO 5-digit numbers, and checks whether each 
input number opens the chest or not. The output should 
be YES, if the chest opens, and NO otherwise.
Homework 2: Due 
Day Monday, Oct 19:
Write a function FtoC  that converts Fahrenheit temperature to
Celsius temperature. 
The equation for converting a Fahrenheit to Celsius is:
Celsius= (5/9)*(Fahrenheit - 32)
Write a function  CtoF that 
converts Celsius
temperature to the correspondent Fahrenheit
temperature.
The equation for converting a Celsius temperature to  
Fahrenheit  is
Fahrenheit=(9*Celsius/5)+32
Write a program that asks user to enter Fahrenheit temperature for TWO 
days 
and finds the corresponding Celsius 
temperatures for these two days. Then the program will ask user to enter  
Celsius temperature for TWO days and 
finds the corresponding Fahrenheit temperature for these TWO days.
 TEST 2 Version 2
 
Loop WHILE and Loop FOR PRACTICE
 LOOP  practice 
1
 
LOOP  practice 
1
 LOOP  practice - Solutions
1
LOOP  practice - Solutions
1
 LOOP  
practice 
2
 LOOP  
practice 
2
 LOOP practice
3
 LOOP practice
3
 Practice
 Practice 
Exam 3 Date: November 6, 2013 
Nov 4 Lecture Practice
Write a function candy that has one parameter - number of children in Halloween 
Party. The 
function generates the number of candy each child received in the party (integer between 1 
and 50) and returns the average number of candy per child. Write a program that randomly 
generates the number of children in the party ( integer between 5 and 10) and test the 
function candy
Exam 3
Mini Quiz Friday Nov 13
 Mini Quiz Friday Nov 13
 
Thanksgiving Break Homework 
Lists in Python 
Future Plans:
- Friday Dec 4 - Mini Quiz
- Monday Dec 7 - Lab Assignment
- Friday Dec 11 - Mini Quiz
-  Lists in 
Python from python.org
- Lecture Practice:
- Problem 1: Write a program that reads 5 grades and creates a list. 
The program finds sum and average of the grades
- Problem 2: Write a program that randomly 
generates the list of 10 integers 
between -100 and 100. The program
finds the sum and average of the 
even elements of the list
- Write a program  that compares two lists of integers.  The 
program finds the number of elements that are the same and on the 
same positions in both lists. Assume that both list have the same length.
- Dec 2: Lecture Practice: Write a program that generates a list of grades (ints between 0 and 100)
Program creates TWO new lists: fail_grade and pass_grade. Program finds the number of failing and the number of passing 
grades and the average grade in each category
 Mini Quiz Dec 4Mini QuizLists and Strings -  Lecture Practice 1
-  Lecture Practice 2
- Lecture Practice 3: Write a function that 
accepts 
one parameter - list of strings. 
The function finds and returns the position 
of the longest string in the list. 
 
 The easy version: in case and there are several strings with maximal 
length, 
function returns one of the positions.
 
 The complex version (BONUS): function returns the list of ALL 
positions of the longest strings
 For example: my_list=['yana', 'bob', 'snow', 'go', 'cat', 'dogs']
 Tha maximal length is 4, and the list of positions will be [0, 2, 5]
Write a program that generates N(user input) lists of strings. For each 
list, 
find the  length of the longest string, the position
of the longest string and the longest string itself using the function you 
wrote.
 
 
 MINI QUIZ DEC 11Mini Quiz Dec 11