Define a function, more_than_5(word), that returns True if word has more than 5 letters, False otherwise.
s = {1, 2, 3}
s.add(1)
s.add(4)
s.update([3, 4, 5])
What is the value of s at the end of execution of the above script?
def to_set(v):
return set(v)
s1 = {1, 2, 3, 3, 3}
s2 = to_set('aan')
Given the above script, what are the values of the following variables?
| s1: | ||
| s2: |
What does the * operator do a tuple and an integer?
|  It multiplies each element inside the tuple by the integer | ||
|  It adds the integer to each element of the tuple | ||
|  It repeats the entire tuple that many times | ||
|  It creates a set with repeated elements |
Write a function that takes one string and returns
its third to sixth (not including sixth) characters. Example:
>>> middle('strings')
'rin'
Write a function that takes two strings, s1, and s2, and returns True if s1 is smaller than (comes before) s2.
d = {1: 1, 2: 2, 3: 4}
first = 2 in d.values()
second = (1 in d) and (1 in d.values())
third = 3 in d.values()
Given the above script?
| What is the the value of first: | ||
| What is the the value of second: | ||
| What is the the value of third: |
house = {'address': 'Llukar', 'number': 19}
Given the above script?
| What is the the value of words: | ||
| What is type of words: | ||
| How many elements does words have: | ||
| What is the value mapped to "number": | ||
| What is the key the value 'Llukar' is mapped to: |
Complete execution flow of the following program
fruit = 'fig' index = 0 while index < len(fruit): letter = fruit[index] print(letter) index = index + 1
Complete execution flow of the following program
def lower(s): return s.lower() s1, s2 = 'python', 'Python' print(lower(s1)) s2 = lower(s2) print(s2)