assignment3 - CMPT 120 Assignment 3(2 Submit your solutions...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CMPT 120 Assignment 3 (2%) Submit your solutions to courses by Saturday, October 9, 2010 2:00pm 1. [6 marks] ASCII Conversion Place your answers in a3q1.txt . (a) [3 marks] Convert the 6-character string “ Hello! ” into ASCII. Use 8 bits per character. (b) [3 marks] The following sequence is encoded in 8-bit ASCII. What is the string? 0100 0111 0010 0111 0100 0100 0110 0001 0111 1001 0010 0001 2. [6 marks] Finding Spaces Write a program that reports every occurrence of a space: Enter a string: The quick brown fox jumps again! There’s a space in position 3. There’s a space in position 9. There’s a space in position 15. There’s a space in position 19. There’s a space in position 25. You can examine the character in position i from the string s , by using indexing: s[i] . The leftmost character of a string is s[0] . For example: if s[0] == ’r’: print "Shiver me timbers!" Hint: The function range(len(s)) will give you the sequence of positions of the characters in the string...
View Full Document

This note was uploaded on 12/31/2010 for the course CS 120 taught by Professor Bradbart during the Fall '10 term at Simon Fraser.

Ask a homework question - tutors are online