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
| a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] | |
| b = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] | |
| common = [] | |
| for item in a: | |
| if item in b: | |
| if item not in common: | |
| common.append(item) | |
| print common |
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
| input_number = input("Enter a number: ") | |
| print ("You entered " + str(input_number)) | |
| number = abs(input_number) | |
| x = range (1, number) | |
| divisors =[] |
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
| #!/usr/bin/python | |
| mylist = a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] | |
| newList = [] | |
| for item in mylist: | |
| if item < 5: | |
| print(item) | |
| newList.append(item) | |
| print(newList) |
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
| number = int(input("Entr a number: ")) | |
| print("Number you entered " + str(number) + ".") | |
| if number % 2 == 0: | |
| print ("Number is even.") | |
| else: | |
| print("Number is odd.") |
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
| name = input ("Give me your name: ") | |
| print ("Your name is " + name) | |
| age = int(input("Enter your age: ")) | |
| print("Your age is " + str(age)) | |
| age_at_hundred = (100 - age) + 2016 | |
| print ("You will be 100 yeras old in " + str(age_at_hundred)) |