CMPUT174 Midterm: cmput174 inclass2.pdf

1309 views8 pages
ceruleanzebra152 and 30 others unlocked
CMPUT174 Full Course Notes
25
CMPUT174 Full Course Notes
Verified Note
25 documents

Document Summary

2014: a function making the user enter a string made of alphabets only! def validstring():! astring=input( enter a string made of alphabets only> )! while (astring. isaplha()==false):! astring=input( try again! *deletelast(mylist)! print(mylist)! main(): when you reduce the list, a new list is not created, 2,4,6 is printed, caller will remember changes that happened to list, variables de ned just within functions, but to each other as well. 2014: assignment 4: only required to use test cases, not asking user for input, code has to cater to any dimension of the matrix, variable names for rows and columns. matrix=list inside a list. Lab 6 one example for matrix multiplication. no error checking, info needed is everything before now: tuple: like a list is a sequence of objects, but it cannot mutate. But object inside can be mutable, then you can change that object. #info split into two separate variable names! name,grade=info. split()! #putting info in tuple data aspect with two structures! record=(name, oat(grade))!