Skip to content

Instantly share code, notes, and snippets.

View iswarup's full-sized avatar
👽
Open to work

Swarup iswarup

👽
Open to work
View GitHub Profile
@iswarup
iswarup / Exercise16.py
Created June 21, 2018 09:53
Password Generators
import random
s = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()_<>?+:"
passlen = 8
p = "".join(random.sample(s,passlen))
m = random.sample(s,passlen)
print (p,m)
import string
@iswarup
iswarup / Exercise13.py
Created June 21, 2018 01:27
Fibonacci Function with user sizelimit.
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
@iswarup
iswarup / Exercise11.py
Last active June 20, 2018 16:42
Prime number. Using Functions. Using LIST Comprehension.
#######################
# Using Functions:
#######################
def get_number(prompt):
return int(input(prompt))
def is_prime(number):
if number == 1:
@iswarup
iswarup / Exercise7.py
Last active June 19, 2018 14:32
List Comprehension. With transpose of a matrix.
# 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)
@iswarup
iswarup / Exercise9.py
Created June 19, 2018 14:21
Guessing game I.
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
@iswarup
iswarup / Exercise6.py
Created June 9, 2018 20:49
Palindrome test
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.")
@iswarup
iswarup / Exercise1.py
Last active June 9, 2018 20:50
datetime
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,".")