@extends('template') @section('title') Lab 6 Warm-up @stop @section('head') @stop @section('content') # Lab 6, Warm-up & Mini-review - Here is the worksheet as a google doc: [[click here for worksheet]](https://docs.google.com/document/d/1Saaopqr_hWvvMZVG9V35-GfzIzpojn7ssDvIAzxWqyM/edit?usp=sharing) {{-- ### Ex 1: Extracting parts of strings ```py word = 'cupcake' word[2] word[3:5] word[1:] ``` ### Ex 2: Using append to create lists ```py nouns = [] nouns.append('apple') nouns.append('bench') nouns.append('canister') nouns.append('donut') ``` + 2a: What is contained in `nouns`? + 2b: Draw the memory diagram of `nouns`. ### Ex 3: For loop mini-review ```py 3a) for item in nouns: print(item) 3b) for n in nouns: ______________ # fill in this blank apple 5 bench 5 canister 8 donut 5 3c) for n in nouns: if 'a' in n: print(n) 3d) for n in nouns: ___________ # fill in these blanks to print `canister` _______ canister ``` --}} {{--### Ex 4: ```py Sample invocations: >>> getAnouns(['john','paul','george','ringo']) ['paul'] >>> getAnouns(['blue','green','red']) [ ] >>> getAnouns(['ana','soobin','paula','emma','eli']) ['ana', 'paula', 'emma'] >>> getAnouns('dog', 'cat', 'bunny') TypeError: getAnouns() takes exactly 1 argument (3 given) ``` --}} {{-- ```py WHILE LOOPS A. # this is a for loop for number in range(5): print(number * '*') B. # this is a while loop number = 1 while number <= 5: print (number * '*') number +=1 C. age = 18 while age < 50: print(age) age += 10 D. name = input('Your name?') while name != 'paula': print('try again') ``` --}} @include('/labs/lab06/_toc') @stop