 List operarions | Sololearn: Learn to code for FREE!

+2

# List operarions

num=(10, 9,8,7,6,5) num=num-5 If 4 in nums: print(num) else: print(num) How's the ans is 7....i cant understand anyone can help me?

+1

num= num - 5 #num is 9 num= 9 - 5 num= 4

+6

In the beginning: num = [10, 9, 8, 7, 6, 5] because: num = num - 5 and num is 9, and num = 4 thus now: num = [4, 9, 8, 7, 6, 5] Because 4 in [4, 9, 8, 7, 6, 5], num, which is 7, is printed.

+2

Num=(10,9,8,7,6,5) Num=num-5 If in nums: Print(nums) Else: Print(nums) It is the answer because they said output nums number 3 And remember when you start counting you start from zero Now the new will be Num=(4,9,8,7, 6, 5) So the third one we will be 7 And if you still don't understand go back to the beginning where the lesson just started it's no big deal

0

Because list first item is the 0, the second item is 1... In this example num is 10, num is 9...

0

num = num -5#num is 9 num=9-5 num=4

0

I'll try and break it down line by line: Line #1 num=(10,9,8,7,6,5) # The list and its contents are provided and assigned to the variable num Line #2 num=num-5 # num is reassigning the value of the 1st element in the list (currently 10) to the difference of the value of the 2nd element (currently 9) minus 5. 9-5=4. The 1st element now has a value of 4. Now, num=(4,9,8,7,6,5) Line #3 If 4 in num: # This is testing if the value of 4 exists in the list assigned to the num variable. If it is True (i.e. the value is found), move on to the next line. If False, move on to Line #6 Line #4 print(num) # This is saying to print the value of the 4th Element in list assigned to the num variable (currently 7) Line #6 print(num) # This is saying to print the 5th element of the list assigned to the variable num (currently 6) if the test in Line 3 were False.

0

nums = [3, 2, 8] print(not 4 in nums) print(4 not in nums) print(not 3 in nums) print(3 not in nums)

-1

Given is num,condition is num=num-5,so we assign num=9-5=4 Go to loop If 4 is print num Result is 4 so we print the 3 num.3 num is 7.so 7 is answer

-1

Coming to 2nd row num which is 10 is asigned ir replaced with num-5 or 9-5 or 4 Now in 3rd row.... 4 in nums is true hence num means 4th numbers will be printed which is 7

-2

List operarions num=(10, 9,8,7,6,5) num=num-5 #num = 10 and num-5 = 9-5 = 4. #we take the number four and we affect to num which is equal to 10,that mean num = 4 now. If 4 in nums: #from what is above we know that the number 4 exists in the list, so the condition is checked. print(num) #like that our condition is checked, so the first print () is executed.which gives us the result as 7, because do you remember that:num=4,num=9,num=8, and num= 7, ...etc else: print(num)