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
import random | |
s = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()_<>?+:" | |
passlen = 8 | |
p = "".join(random.sample(s,passlen)) | |
m = random.sample(s,passlen) | |
print (p,m) | |
import string |
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
def get_integer(prompt): | |
return int(input(prompt)) | |
size= get_integer("Enter the number of numbers you want in the fibonacci sequence: ") | |
def fib(size): | |
a,b = 0,1 | |
list=[a] | |
while len(list) < size: | |
a,b = b,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
####################### | |
# Using Functions: | |
####################### | |
def get_number(prompt): | |
return int(input(prompt)) | |
def is_prime(number): | |
if number == 1: |
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 = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100] | |
# years_of_birth = [1990,1992,1991,1999,1995,1998,1992,1994,1929,1953,2001] | |
# ages = [] | |
# for year in years_of_birth: | |
# ages.append(2018-year) | |
# print(ages) | |
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
import random | |
number= random.randint(1,9) | |
count= 0 | |
guess= 0 | |
while guess != number: | |
guess= input("Guess the number or type exit to exit. ") | |
if guess == "exit": | |
break |
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
string=input("Enter a string to check if it is a palindrome: ") | |
if string[::1] == string[::-1]: | |
print(string,"is a palindrome.") | |
else: print(string,"is not a palindrome.") |
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
name=input("Enter your name:") | |
age=int(input("Enter your age:")) | |
import datetime | |
now= datetime.datetime.now() | |
age100= now.year + (100-age) | |
print("Hello "+name+". "+"You will turn 100 in",age100,".") |