IN PYTHON 3 LANGUAGE
The windows generator takes an iterable and two ints (call them n and m; with m’s default value 1) as parameters: it produces lists of n values: the first list contains the first n values; every subsequent list drops the first m from the previous list and adds the next m values from the iterable, until there are fewer than n values to put in the returned list.
call iter and next directly, and use a list that always contains n values, so it doesn’t violate the conditions for using iterables
SAMPLE OUTPUT:
For example:
for i in windows('abcdefghijk', 4,2):
print(i,end='')
prints ['a','b','c','d'] ['c','d','e','f'] ['e','f','g','h'] ['g','h','i','j'].
for i in windows('abcdefghijk', 3,2):
print(i,end='')
prints ['a', 'b', 'c'], ['c', 'd', 'e'], ['e', 'f', 'g'], ['g', 'h', 'i'], ['i', 'j', 'k']
def windows(itr, n, m):
lst = []
index = 0
for i in range(index, len(itr)):
l = []
for j in range(n):
if j + index < len(itr):
l.append(itr[j + index])
if len(l) == n:
lst.append(l)
index += m
return lst
for i in windows('abcdefghijk', 4, 2):
print(i, end='')
print()
for i in windows('abcdefghijk', 3, 2):
print(i, end='')

IN PYTHON 3 LANGUAGE The windows generator takes an iterable and two ints (call them n...
Please explain the python code below L1 = [2, 15, 'Carol', 7.4, 0, -10, -6, 42, 27, -1, 2.0, 'hello', [2, 4], 23] print("L1 =",L1) odds =[] evens=[] list=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',',','.'] no=0 for i in L1: i=str(i) for j in list: if i.find(j)>=0: no=1 if no==1: None else: i=int(i) if i%2==0: evens.append(i) else: odds.append(i) no=0 ...
i have a huge json file , it has a key call type(the type of crime commited), date and time(date crime was commited) , and location(address or lat&long) among other keys with values. Im mostly interested in counting the days with the most crimes , counting what call types show up the most, and what location shows up the most also, the location can measure by the home address or pairing the latitude and longitude together. Python would probably be...
write the solution of the program by python 3 language : I need the program using list : You are given a non-decreasing sequence of n positive integers a1,a2,…,an. Print the number of distinct values in the sequence. For example, if the sequence is 1,2,2,2,3,4,4,5,7,10, the answer is 6 since distinct values are 1,2,3,4,5,7,10. Input The first line contains a positive integer n (1≤n≤1000) — the length of the sequence. The second line contains n space-separated positive integers a1,a2,…,an (1≤ai≤1000)...
I was asked this question:Given any input series a corresponding graph must be generated without the use of any libraries.After, trying my best, I arrived at this solution to which they replied it had a logical issue.# Create the matrix print("Enter the sequence with spaces: ") arr = list(map(int, input().split())) count = len(arr) rows = int(sum(arr)) cols = int(sum(arr) + 4) content = [[" "]*cols for _ in range(rows)] maxq = 0 maxp = 0 content[0][0] = "/" # Apply the positions in the matrix p = 0 q = arr[0] k = 0 for l in range(q): if (k != q): content[k][p] = "/" p = p + 1 k = k + 1 p = q flag = 1 i = 0 j = 0 k = 0 c = 0 temp = 0 r = 0 flag = 1 for i,j in enumerate(arr): c = c + 1 if c < count: k = arr[i+1] else: k = 0 if arr[i]: if flag == 1: content[q][p] = "/\\" if maxq < q: maxq = q maxp = p qori = q pori = p p = p + k temp = q - k...
Create two Java classes called Recursive, RecursiveDemo. Write four methods a- int sum_sqr_rec(stack<int> stk) which will receive a stack of "int" and output the sum of the squares of the elements in the stack. b- int plus_minus_rec(stack<int> stk) which will receive a stack of "int" (example: {a,b,c,d,e,f,g,h,i,j}) and output the sum of the elements in the stack as follows: a - b + c - d + e - f + g - h + i -j c- void prt_chars_rev_rec(stack<char>...
A stock is currently selling for $68.96. A call option expiring in 194 days with a strike price of $65.00 is selling for $8.12; A put option expiring in 133 days with a strike price of $70.00 is selling for $4.57. What is the call option's exercise value? a. $0.00 b. $0.20 c. $0.43 d. $0.61 e. $0.69 f. $1.04 g. $2.22 h. $2.49 i. $3.12 j. $3.53 k. $3.55 l. 3.96 m. $4.16 n. $4.57 o. $5.00 p. $6.74...
1) Suppose that a directed graph contains the following edges. Find the strongly connected components. {(h, i), (i, j), (j, k), (k, h), (l, m), (m, n), (n, p), (p, l), (f, i), (c, e), (j, b), (k, l), (a, b), (b, c), (c, a), (d, e), (e, f), (f, g), (g, d)}. a) How many vertices are there in the component having the smallest number of vertices? b) How many vertices are there in the component having the second...
ints) For the following mechanism: a. Determine the number of links in the mechanism b. Determine the total joint order in the mechanism c. Determine the number of loops required for this mechanism d. Determine the mobility of this mechanism e. Draw an appropriate vector loop for this mechanism f. Write the vector loop equation(s) in vector form. g. Write the scalar components of the vector loop position equations. h. Determine any geometric constraint equations. i. Determine the scalar known(s)....
This is a Python Program Write a program that encrypts letters based on the following key. Original letter to encrypted letter A M B L C K D J E I F H G G H F I E J D K C L B M A N Z O Y P X Q W R V S U T T U S V R W Q X P Y O Z N Write the output to a file
using C++ Write a program that: a) Inputs an integer n from the keyboard where n<=100. If n is out of range then print out an error message and ask for another input. This process repeats until a valid value for n is obtained. b) Inputs two 1D arrays of doubles A and B (of size n) from the keyboard. c) Inputs an integer k (from 1 to 3) from the keyboard. d) If k = 1 then it calculates...