CSCA20 - WORKSHEET 3.pdf

1 Page
285 Views
Unlock Document

Department
Computer Science
Course
CSCA20H3
Professor
Anya Tafliovich
Semester
Summer

Description
CSCA20  For the index 3 (inclusive) to the index - Worksheet 3 2 (exclusive)  Strings  s[-5:] = „fspam‟  Basics  Iterate over the indices of a string  Using either single or double quotes  def print_vertical(s):  „csca20‟ or “csca20”  for index in range (len(s)):  „csca‟ + „20‟ = „csca20‟  print (s[index])  „2‟ + „5‟ = „25‟  Explanation:  „+‟ is overloaded, means more than one  range (6) means range (0,6) function  range (0,6) means a group of  „ho‟ * 3 = „hohoho‟ numbers and the numbers are 0, 1,  3 * „ho‟ = „hohoho‟ 2, 3, 4, 5  „ou‟ in „colour‟, return True  range (0, 6)  len („hohoho‟) = 6  0 is inclusive  Escape sequences  6 is exclusive  \‟ singe quote  range is similar to list, we will cover  \” double quote in the next worksheet  \\ backslash  Printing strings: conversion specifiers  \t tab  Example:  \n newline  Print (“The maximum of the three grades  \r carriage return (not necessary) (%d, %d and %d) is %d” %(a1, a2, a3, max(a1, a2, a3)))  \ and hit enter, skip to new line to make coding seems nice  % is operator with two operands:  print („one\ttwo\tthree‟)  A string on the LHS and a
More Less

Related notes for CSCA20H3

Log In


OR

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Sign up

Join to view


OR

By registering, I agree to the Terms and Privacy Policies
Already have an account?
Just a few more details

So we can recommend you notes for your school.

Reset Password

Please enter below the email address you registered with and we will send you a link to reset your password.

Add your courses

Get notes from the top students in your class.


Submit