Walk through previous lecture Binary/Octal/Hexadecimal Numers - - PowerPoint PPT Presentation

walk through previous lecture binary octal hexadecimal
SMART_READER_LITE
LIVE PREVIEW

Walk through previous lecture Binary/Octal/Hexadecimal Numers - - PowerPoint PPT Presentation

Walk through previous lecture Binary/Octal/Hexadecimal Numers Given a binary number How to convert it to decimal numbers Given a decimal number How to convert it to binary numbers Same question for other types: Octal and


slide-1
SLIDE 1

Walk through previous lecture

slide-2
SLIDE 2

Binary/Octal/Hexadecimal Numers

  • Given a binary number

– How to convert it to decimal numbers

  • Given a decimal number

– How to convert it to binary numbers

  • Same question for other types: Octal and

Hexadecimal.

slide-3
SLIDE 3

Functions in Python

Syntax: def function_name (parameters) : """ Function documentation goes here """ Example: (function_ex1.py) >>> # Function definition is here ... def printer( p1 ): ... """ This function just prints two strings """ ... print "This prints a passed string into this function" ... print p1 ... return ... # Now we can call printer function """ >>> printer ("I'm the first call to printer function!") This prints a passed string into this function I'm the first call to printer function!

slide-4
SLIDE 4

Test Driven Development

  • Given a problem
  • First write tests for the solution function you

want to implement

  • Let the test fail
  • Implement the actual function that helps the

tests to pass

slide-5
SLIDE 5

ToDo

  • Install setuptools on your machine
  • Make sure “easy_install” works on your

machine

  • Install

– pytest – coverage

slide-6
SLIDE 6

Sorting

  • Implement a function mysort
  • Takes a list of n numbers
  • Outputs them in sorted order
  • First write :

– test_mysort()

  • Use py.test to discover that test, run it and

make sure your test passes

slide-7
SLIDE 7

to be continued...