Answer:
The Python code with the function is given below. Testing and output gives the results of certain chosen parameters for the program
Explanation:
def first_last(seq):
if(len(seq) == 0):
return ()
elif(len(seq) == 1):
return (seq[0],)
else:
return (seq[0], seq[len(seq)-1])
#Testing
print(first_last([]))
print(first_last([1]))
print(first_last([1,2,3,4,5]))
# Output
( )
( 1 , )
( 1 , 5 )
<span>The Huns were a formidable force to fight. They were able to eat most food without problem which removes the needs for supply trains and such and encourages pillaging. Another reason is that their a cavalry based army which completely decimated roman military since the roman empire consist of flat land and they could outflank, outrun, and could whittle down an army with ease. They also are nomads which means you don't know where they're living and so you can't be on the attack which also gave an advantage. This points that the Huns are a force to be reckon with.</span>
Answer:
import random
randomlist = []
for i in range(0,20):
n = random.randint(-29,30)
if n < 0 :
n = 100
randomlist.append(n)
print(randomlist)
Explanation:
The random module is first imported as it takes care of random. Number generation.
An empty list called randomliay is created to hold the generated random integers.
Using a for loop, we specify the range of random numbers we want.
Inside the for loop ; we attach our generated random integer which will be in the range (-29 to 30) in a variable n
For each n value generated, if the value is less than 0( it is negative, since all the values are integers), replace the value with 100.