python website projects code example

Example 1: python projects with source code for beginners

##-Guess The Number. Write a programme
## where the computer randomly generates
##a number between 0 and 20

from random import randint
    
print("Hey there! In this game, you will have to guess a random number from 1, 20. Good luck!")
user_name = input("What's your name?\n")

print(user_name,"pick a number!")
guess = input()

random_int = randint(0, 20)

if guess != random_int:
    print('That was wrong!', random_int, "was the number!")
else: 
    print('That was correct!')

Example 2: python projects with source code for beginners

#Password generator 

import random
import string

letters = string.ascii_letters
print('Your brand new password is:')
print (''.join(random.choice(letters) for i in range(12)))