Answer:
def short_strings(string_list):
short_list = []
for s in string_list:
if len(s) < 20:
short_list.append(s)
return short_list
Explanation:
* The code is in Python.
- Create a function called short_strings that takes one parameter, string_list
- Create an empty list called short_list to hold the strings that are less than 20 characters
- Initialize a for loop that iterates through the string_list. Check if there are strings that are less 20 characters in the string_list. If found, put them in the short_list
- Return the short_list
Answer:
#code (count_seq.py)
def count_seq():
n='2'
while True:
yield int(n)
next_value=''
while len(n)>0:
first=n[0]
count=0
while len(n)>0 and n[0]==first:
count+=1
n=n[1:]
next_value+='{}{}'.format(count,first)
n=next_value
if __name__ == '__main__':
gen=count_seq()
for i in range(10):
print(next(gen))
Explanation:
- Start with number 2. Use string instead of integers for easy manipulation
.
- Loop indefinitely
.
- Yield the integer value of current n
.
- Loop until n is an empty string
.
- Loop as long as n is non empty and first digit of n is same as first
.
- Append count and first digit to next_value
.
Answer:
Go into short-term memory
Explanation:
Data stored on physical storage devices must go into short-term memory before the processor can access it.
This is because, physical storage devices are secondary memory which store information for a long time. The CPU does not work directly with secondary memory but with primary or short term memory. Since the CPU works mainly with short term memory, information in physical storage or secondary memory has to go into short term memory for the CPU to be able to process it.
<u>So, data stored on physical storage devices must go into short-term memory before the processor can access it.</u>