Course and Reading Material

Weeks 1-2: Lecture

Introduction to Computers


Binary System

Decimal to Binary

Storing Characters

Steganography Example - Practice

Decimal/Binary Converter

Wolfram|Alpha: Computational Knowledge Engine

Decimal ASCII Chart

Material for Mini Quiz 1 Friday Sept 6

  • Conversion from decimal to binary (two methods)
  • Conversion from binary to decimal

    Mini Quiz 1 Structure

    Exampes

    1. Convert binary number 1100 1101 to decimal
      Solution: add power of 2 that corresponds to the bits that are ON ( bits that are equal 1):
      128 + 64 + 8 + 4 + 1 = 205

      Final answer: 205 is decimal equivalent of binary number 1100 1101

    2. Convert decimal 38 to binary:
      Solution Method 1:
      128 fits into 38? NO b7 = 0
      64 fits into 38? NO b6 = 0
      32 fits into 38? YES b5 = 1
      38 - 32 = 6
      Continue with 6:
      16 fits into 6? NO b4 = 0
      8 fits into 6? NO b3 = 0
      4 fits into 6 YES b2 = 1
      6 - 4 = 2
      Continue with 2:
      2 fits into 2? YES b1 = 1
      2-2 = 0
      Continue with 0:
      1 fits into 0? NO b0 = 0

      Final answer: Decimal number 38 in binary is 0010 0110

      Method 2 using Integer Division and Remainder:
      38 / 2 = 19 remainder 0 b0 = 0
      19 / 2 = 9 remainder 1 b1 = 1
      9 / 2 = 4 remainder 1 b2 = 1
      4 / 2 = 2 remainder 0 b3 = 0
      2 / 2 = 1 remainder 0 b4 = 0
      1 / 2 = 0 remainder 1 b5 = 1
      As soon as we got 0 the process is stopped and the rest of the bits are 0: b6 = 0, b7 =0

      Final Answer: Decimal number 38 in binary system is: 0010 0110

    3. Convert binary number 0100 0100 to decimal
      Solution: add power of 2 that corresponds to the bits that are ON ( bits that are equal 1):
      64 + 4 = 68

      Final answer: 68 is decimal equivalent of binary number 0100 0100

    4. 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

      MINI QUIZ Sept 6, 2019


    Week 3:

    Mini Quiz 2 Friday Sept 13 Structure and Material:

    Week 3 Programming with Python:

    Online Resource

    Input and Formatted Output in Python:


    Mini Quiz 2 Preparation

    Mini Quiz 2 Preparation

    Mini Quiz 2 Version 2 (count starts from the wall in each sit row)

    TEST 1 on Friday, Sept 21

    TEST 1 Structure


    Test 1 Preparation Part I


    Test 1 Preparation Part II



    Test 1

    IF IF-ELSE IF-ELIF-ELSE Statements

  • Mini Quiz 3 Preparation

    Quiz 3

  • Mini Quiz 3 Version 1

  • Mini Quiz 3 Version 2

  • Test 2 Preparation - Loop Examples

  • Test 2 Date: Monday Oct 14
  • TEST 2 Version 1
  • TEST 2 Version 2

  • Lists and Strings

  • Lecture Practice: 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.