Question: I need help for this in python. a) Write a list comprehension that returns all tuples (a,b,c), with a,b,c integers, such that 1
I need help for this in python.
a) Write a list comprehension that returns all tuples (a,b,c), with a,b,c integers, such that 1<=a,b,c<=100 and a2+b2=c2.
b) Consider a list of strings, like this: ['one', 'seven', 'three', 'two', 'ten']. Write a list comprehension that produces a list with tuples where the first element of the tuple is the length of an element in the initial list, the second element of the tuple is the element of the initial list capitalized, and the resulting list contains only tuples for strings with the length longer than three characters. For our example the list comprehension should return [(5, 'SEVEN'), (5, 'THREE')].
c) Consider a list of full names (formatted Firstname Lastname), like["Jules Verne", "Alexandre Dumas", "Maurice Druon"]. Write a list comprehension that produces a list with the full names in this format: Lastname, Firstname. The resulting list should look like ['Verne, Jules', 'Dumas, Alexandre', 'Druon, Maurice']. The simplest solution may involve a nested comprehension: [ . for in [ for in ]].
d) Write a function called concatenate that takes as parameter a separator (a string) and an arbitrary number of additional arguments, all strings, and that returns the concatenation of all given strings using the given separator.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
