Building password generator– Python

Password generator:

This password generator, you can change the password length and character of possible passwords

Used: import random , for

pass.png
To copy or see all commands you can click on Details button below

 

 

#!/usr/bin/python

”’
author: Hopeless
task: prog will generate random password according to user defined length
”’

import random

allchars = ‘abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890~!@#$%^&*()-=+?’

passlen = 10
password = ”

for i in range(0,passlen):
password += allchars[random.randrange(0,len(allchars))]

print password

 

 

Untitled.png

Advertisements

Building finder palindrome – Python

Palindrome check:

this program check if a string is a palindrome

Used: for , if , else

palindrome.png
To copy or see all commands you can click on Details button below

 

#!/usr/bin/python

”’
author: Hopeless
task: check if a string is a palindrome
”’

string = raw_input(‘[*] enter your string: ‘)

#rev_string
rev_string = ”

for i in range(len(string)):
rev_string += string[len(string)-i-1]

if rev_string==string:
print True
else:
print False
print

print rev_string
print string

 

Untitled.png

Building prime numbers finder – Python

Prime number finder:

This program checks if the selected number is prime or not, if not Prime program shows all the numbers which is divided

Used: if , else

prime.png
To copy or see all commands you can click on Details button below

 

#!/usr/bin/python
”’
author: Hopeless
task: Prime number finder: write a script that checks if a number is a prime number and devisor_list.
”’

print ‘\nthis program will check if number is prime or not’
num = input (‘enter your number: ‘)
devisor = ”
devisor_list = []

if num == 1:
print ‘prime!’
else:
for i in range(2,num/2+1):
if num%i == 0:
devisor = i;
devisor_list.append(devisor)

if len(devisor_list):
print num, ‘is not a prime number \ndevided by ‘ , devisor_list
else:
print num, ‘is prime number!’

 

Untitled.png

Improve Prime number finder:

This program request lower number and a higher number, the program displays all the prime numbers that are within range

Used: for , if , else , break

primerange.png
To copy or see all commands you can click on Details button below

 

#!/usr/bin/python
”’
author: Hopeless
task: Improved Prime number finder: write a script that finds all prime numbers within a range
(ex: 2,000-8,000),range will be given by user
”’

print ‘\nthis program will check if number is prime or not’
print ‘Please enter a range of numbers first the low number to high’
num = input (‘enter your lower number in range: ‘)
num1 = input (‘enter your upper number in range: ‘)

for numbers in range(num,num1 + 1):
if numbers == 1:
print ‘1 = prime!’
else:
for i in range(2,numbers/2+1):
if (numbers%i) == 0:
break
else:
print (numbers)

 

Untitled1.png

Building lottery numbers – Python

Lottery number:

This software selecting 6 random numbers between 1-37, the number can not go back twice

Used: import random , for

lotto.png

To copy or see all commands you can click on Details button below

 

 

#!/usr/bin/python
”’
author: Hopeless
task: lottery number , number can not return twice
”’
import random
#all numbers = range (1,37)
allnumbers = range(1,38)
winningNums = []

for i in range(1,7):
num = allnumbers[random.randrange(0,len(allnumbers))]
winningNums.append(num)
allnumbers.remove(num)

winningNums.sort()
print winningNums

 

 

Untitled.png