This file contains 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, b = set(raw_input("Enter Set 1: ")), set(raw_input("Enter Set 2:")) | |
print "Similar elements = {} ".format(a&b) |
This file contains 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
n = int(input("Enter your number")) | |
d = n - 1 | |
x = 2 | |
dvr = [] | |
while 2 <= x <= d: | |
y = n % x | |
if y == 0: | |
dvr.append(x) | |
x += 1 | |
else: |
This file contains 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(raw_input("Enter number: ")) | |
if num % 2 == 0 and num % 4 != 0: | |
print '%d is Even number' % num | |
elif num % 4 == 0: | |
print '%s is multiples of Four' % num | |
else: | |
print '%d is odd number' % num |
This file contains 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
##Century Calculator | |
import datetime | |
name = raw_input("Enter your name:") | |
age = int(input("Enter your age:")) | |
times = int(input("How many times you want to print this message")) | |
now = datetime.datetime.now() | |
century = int((100 - age) + now.year) | |
print "\nHello \"%s\" you will attain 100th age in %sth year." % (name, century) * times |