Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 95 additions & 0 deletions Bell_number.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "Bell_number.ipynb",
"provenance": []
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "3Ns1F3dzP0yP"
},
"source": [
""
]
},
{
"cell_type": "code",
"metadata": {
"id": "rjT0RXpvP1F4",
"outputId": "8a6215dc-8758-4ced-e685-0bed0f2be464",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 495
}
},
"source": [
"#Python program to print bell number\n",
"#Bell Number:-Let S(n, k) be total number of partitions of n elements into k sets. The value of n’th Bell Number is sum of S(n, k) for k = 1 to n. Value of S(n, k) can be defined recursively as, S(n+1, k) = k*S(n, k) + S(n, k-1)\n",
"#A sample Bell triangle is as follows:\n",
"#1\n",
"#1 3\n",
"#3 8 13\n",
"#13 23 33 43\n",
"#The code to print the bell triangle is as follows-\n",
"#---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n",
"n=int(input(\"Enter the number of bell\")) #taking value from the user\n",
"bell=0 #initialising bell to 'zero'\n",
"k=0 #initialising k to 'zero'\n",
"for i in range(n): #loop for changing rows from 0 to n\n",
" for j in range(i+1): #printing columns\n",
" if j==0 and i>0: #repeating the last number of previous row in new row\n",
" print(bell,'',end='') #printing first number of each line\n",
" else:\n",
" k=(i**2)+1+bell #to generate other numbers of line\n",
" print(k,'',end='') #printing other number in lines\n",
" bell=k #updating value of bell \n",
" print('\\n') #for moving into next lines \n",
"print( f\" The last number of bell is {bell}\") "
],
"execution_count": 3,
"outputs": [
{
"output_type": "stream",
"text": [
"enter the number of bell12\n",
"1 \n",
"\n",
"1 3 \n",
"\n",
"3 8 13 \n",
"\n",
"13 23 33 43 \n",
"\n",
"43 60 77 94 111 \n",
"\n",
"111 137 163 189 215 241 \n",
"\n",
"241 278 315 352 389 426 463 \n",
"\n",
"463 513 563 613 663 713 763 813 \n",
"\n",
"813 878 943 1008 1073 1138 1203 1268 1333 \n",
"\n",
"1333 1415 1497 1579 1661 1743 1825 1907 1989 2071 \n",
"\n",
"2071 2172 2273 2374 2475 2576 2677 2778 2879 2980 3081 \n",
"\n",
"3081 3203 3325 3447 3569 3691 3813 3935 4057 4179 4301 4423 \n",
"\n",
"last number of bell is 4423\n"
],
"name": "stdout"
}
]
}
]
}
130 changes: 130 additions & 0 deletions Game_of_Rock,Paper,Scissors.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "Game_of_Rock,Paper,Scissors.ipynb",
"provenance": []
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
}
},
"cells": [
{
"cell_type": "code",
"metadata": {
"id": "hynDT8gLTPzO",
"outputId": "d69db102-db7c-47cb-a9d4-5d96d4ad42ed",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 311
}
},
"source": [
"from random import choice\n",
"\n",
"rps = ('rock', 'paper', 'scissors')\n",
"rps_dict = {\n",
" 'rock': {'strong': 'scissors', 'weak': 'paper'},\n",
" 'paper': {'strong': 'rock', 'weak': 'scissors'},\n",
" 'scissors': {'strong': 'paper', 'weak': 'rock'}\n",
"}\n",
"\n",
"\n",
"def print_result(user_score, com_score, win, lose, tie):\n",
" print('Result:', end=' ')\n",
" if user_score > com_score:\n",
" print('You win!')\n",
" elif user_score < com_score:\n",
" print('You lose...')\n",
" else:\n",
" print('Draw.')\n",
" print('--------------------')\n",
" # Print scores\n",
" print(f'Your score: {user_score}')\n",
" print(f'Computer score: {com_score}')\n",
" print('--------------------')\n",
" # Print statistics\n",
" print(f'Win: {win}')\n",
" print(f'Lose: {lose}')\n",
" print(f'Tie: {tie}')\n",
"\n",
"\n",
"def play(rounds):\n",
" game_result = {\n",
" 'user_score': 0,\n",
" 'com_score': 0,\n",
" 'win': 0,\n",
" 'lose': 0, \n",
" 'tie': 0\n",
" }\n",
" while rounds > 0:\n",
" user_input = input(\n",
" 'Enter your choice (1: Rock, 2: Paper, 3: Scissors, 0: Quit): ')\n",
" # Check whether the input is in the options\n",
" if user_input in ('1', '2', '3'):\n",
" rounds -= 1\n",
" user_hand = rps[int(user_input) - 1]\n",
" com_hand = choice(rps)\n",
" # user_hand is strong against com_hand\n",
" if rps_dict[user_hand]['strong'] == com_hand:\n",
" game_result['user_score'] += 1\n",
" game_result['win'] += 1\n",
" result = 'You win!'\n",
" # user_hand is weak against com_hand\n",
" elif rps_dict[user_hand]['weak'] == com_hand:\n",
" game_result['com_score'] += 1\n",
" game_result['lose'] += 1\n",
" result = 'You lose...'\n",
" # Tie\n",
" else:\n",
" game_result['tie'] += 1\n",
" result = 'Tie.'\n",
" print(\n",
" f'You -> {user_hand}. Computer -> {com_hand}. {result}')\n",
" elif user_input == '0':\n",
" break\n",
" else:\n",
" print('Invalid input!')\n",
" print()\n",
" print_result(**game_result)\n",
"\n",
"\n",
"if __name__ == \"__main__\":\n",
" print('Welcome to Rock-Paper-Scissors Game!')\n",
" try:\n",
" rounds = int(input('How many rounds you want to play? '))\n",
" play(rounds)\n",
" except ValueError:\n",
" print('Please input a valid number!')"
],
"execution_count": 1,
"outputs": [
{
"output_type": "stream",
"text": [
"Welcome to Rock-Paper-Scissors Game!\n",
"How many rounds you want to play? 2\n",
"Enter your choice (1: Rock, 2: Paper, 3: Scissors, 0: Quit): 1\n",
"You -> rock. Computer -> paper. You lose...\n",
"\n",
"Enter your choice (1: Rock, 2: Paper, 3: Scissors, 0: Quit): 2\n",
"You -> paper. Computer -> rock. You win!\n",
"\n",
"Result: Draw.\n",
"--------------------\n",
"Your score: 1\n",
"Computer score: 1\n",
"--------------------\n",
"Win: 1\n",
"Lose: 1\n",
"Tie: 0\n"
],
"name": "stdout"
}
]
}
]
}
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# Python-Projects-for-Beginners-

The projects included in this repository are straightforward and easy to code. Beginners can start of with these projects to develop their skills.
The simple projects included in this repository are straightforward and easy to code. They implement basic level Python programming only. Beginners can start off with these projects to develop their skills.

Following are some of the undertaken projects:
1. Password Generator: In this project you will create a program to generate passwords for you,using the random module in Python3.
2. Guess Game : In this project you will create a guessing game,in which user make attempts to identify the number chosen by the computer.

3. Tic Tac Toe Game : This is a two player based "tic tac toe game", using various Python modules.
4. Credit Card Validator : Simple implementation of the "Luhn Algorithm" or Mod 10 Algorithm, verifies a valid credit card number.
1. Basic Password Generator using Python: This project allows you to create a program to generate passwords for you using the random module in Python3.

2. Python Guessing Game : This project is about creating a guessing game where the user makes attempts to identify the number chosen by the computer.

3. Tic Tac Toe Game using Python : This is a two player based "tic tac toe" game using various Python modules.

4. Credit Card Validator using Python : This project showcases one of the simple implementations of the "Luhn Algorithm" or Mod 10 Algorithm, which verifies a valid credit card number.