This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| list1 = [1, 2, 3, 8, 4, 2, 5, 4, 6] | |
| # variable to store the sum | |
| sum = 0 | |
| # iterate over the list | |
| for val in list1: | |
| sum = sum+val | |
| print("The sum is", sum) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| num = int(input("Enter a number: ")) | |
| if (num % 2) == 0: | |
| print(num,"is a even number") | |
| else: | |
| print(num,"is a odd number") |