CSCI 1105 Lecture 15: CSCI 1105 Lists Part II

63 views2 pages
Verified Note

Document Summary

Create a list called words co(cid:374)tai(cid:374)i(cid:374)g two stri(cid:374)gs, (cid:862)yes(cid:863) a(cid:374)d (cid:862)no(cid:863) words = [(cid:862)yes(cid:863), (cid:863)no(cid:863)] Create a list called primes that contains the first five prime numbers. primes = [2, 3, 5, 7, 11] The highest is 9 and the lowest is 0. values[0] = 10 values[9] = 10. Create a list called words that has ten elements, each an empty string. words = [(cid:862)(cid:863)]*(cid:1005)(cid:1004) Filling a list: values = [] for i in range(n): Combining list elements values. append(i*i) result = 0. 0 for element in values: result += element. A students quiz marks are given to you, to find the minimum grade and remove it. You are given a list, and you want to switch the first and second half. Swap the first of the first half with the first of the second half, and so on. values = [9,13,21,4,11] print(values) i=0 j=len(values)//2 while i < len(values)//2: temp = values[i] values[i] = values[j] values[j] = temp i +=

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents