Download presentation
Presentation is loading. Please wait.
Published byGeraldine Webster Modified over 9 years ago
1
Week 7 : String and photo processing
2
Today’s Tasks Practice list and string Convert Decimal to any radix base number Between Binary and Hexadecimal Practice more photo processing Skewing Caution: Delete your script files (*.py) before shutting down your PC!
3
Number Conversion (1/3) How to convert? Use quotient & remainder Divide the quotient by the radix base number until the quotient is 0 Write remainders in reverse order As a result, octal equivalent of decimal number 140 is 214
4
Number Conversion (2/3) Define a conversion function User Inputs Number - positive integer Radix - between 2 and 16 Output Just digits, no gap or another character 123 (O) ‘1’ ‘2’ ‘3’ (x) “Wrong input!!!” if inputs are not in range You must use the formatting operator % (TAs will check!!!) You should implement 2 programs 1. Use a list variable (e.g. converted_number=[]) Print a list to a string use join() 2. Use a string variable (e.g. converted_number =“”) def deci_to_any(n, radix) :
5
Number Conversion (3/3) >>> [evaluate dec_to_any.py] Enter a number: 10 Enter a radix: 2 10 in base 10 is 1010 in base 2 >>> [evaluate dec_to_any.py] Enter a number: 61 Enter a radix: 16 61 in base 10 is 3D in base 16 >>> [evaluate dec_to_any.py] Enter a number: 5 Enter a radix: 17 Wrong Input!!! >>> [evaluate dec_to_any.py] Enter a number: -5 Wrong Input!!!
6
Skewing (1/2) Create the image skewed on an angle from the vertical or horizontal Input img Direction Angle Output Vertical -30 Horizontal -30 Horizontal 30 Vertical 30
7
Skewing (2/2) Define a skewing function User Inputs Direction – vertical or horizontal Angle – between -89 and 89 Output Create a new skewed image “Wrong input!!!” if inputs are not in range You can use math functions or built-in functions pi, sin, cos, tan, radians, … abs Type conversion def skew(img, …) : 30° ?
8
Any Questions?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.