Hangman Game in Python | Python Project #3 | Python Project for beginners

  Рет қаралды 56,679

Jenny's Lectures CS IT

Jenny's Lectures CS IT

Жыл бұрын

In this Python Lecture we are going to build Hangman Game . We will discuss the Complete Code line-by-line. The game will allow for user input, and will also output a visual of the hangman alongside the word that’s being guessed.
Best Python Tutorials for Beginners: • Python - Basic to Advance
*********************************************
Connect & Contact Me:
My Second Channel Link: bit.ly/354n7C7
Facebook: / jennys-lectures-csit-n...
Quora: www.quora.com/profile/Jayanti...
Instagram: / jayantikhatrilamba
Twitter: / khatrijenny
*******************************************
More Playlists:
Programming in C Tutorials: • Programming in C
C++ Tutorials for beginners: • Lec 1: How to Install ...
Placement Series: • Placements Series
Data Structures and Algorithms: https: • Data Structures and Al...
Design and Analysis of Algorithms(DAA): • Design and Analysis of...
Dynamic Programming: • Dynamic Programming
Operating Systems tutorials: // • Operating Systems
DBMS Tutorials: • DBMS (Database Managem...
#pythonprojects #pythonforbeginners #python #jennyslectures #pythonprogramming #hangman

Пікірлер: 96
@lifebyvikk6751
@lifebyvikk6751 8 ай бұрын
I just like how you break complex problems into small problems in order to have them solved,, the way you pause and think and write code is very helpful for someone who wants to really learn how to solve programming problems not only in python but any language for that matter! Thank you Jenny!
@BCKSPCEMusic
@BCKSPCEMusic Жыл бұрын
Well this was really crazy in a good way, i don't know if this channel is for explaining kids but i am 24years old & enjoying it
@Arceus948
@Arceus948 Жыл бұрын
Mam pls start machine learning Playlist, i beg u 😭😭🙏🏻🙏🏻🙏🏻
@santhoshk2722
@santhoshk2722 Жыл бұрын
I'm also waiting for that
@jyoth2009
@jyoth2009 Жыл бұрын
Yes mam
@ShivamSingh-ez5dc
@ShivamSingh-ez5dc 9 ай бұрын
Yes
@lifebyvikk6751
@lifebyvikk6751 8 ай бұрын
I think she has already done a superb job teaching python, I would probably master python well first if I were you
@Arceus948
@Arceus948 8 ай бұрын
@@lifebyvikk6751 i have already mastered python bro, now i want to learn ML
@shivateja3123
@shivateja3123 Жыл бұрын
just subscribed and started watching
@glps369
@glps369 11 ай бұрын
Thank You So Much
@sachinwankhede3346
@sachinwankhede3346 4 ай бұрын
8:48 match expressions😊
@tmurari9452
@tmurari9452 Жыл бұрын
Mam please tell how to draw this Hangman pictures
@Khan_aamir.
@Khan_aamir. 2 ай бұрын
Thank you so much mam😊😊😊😊
@subratkumarsahoo1946
@subratkumarsahoo1946 4 ай бұрын
waah didi waaah..waah didi waah...what an explanation?
@yogendrathakur8053
@yogendrathakur8053 Жыл бұрын
Very good 🎉😂
@ngsscofficial
@ngsscofficial 11 күн бұрын
THANK YOU SO MUCH MAAM
@munamarziya2546
@munamarziya2546 Жыл бұрын
Ma'am you better start your own college,,,,,,i am from non cs branch,,,,,you will get me and my friends as students for sure 🥺
@santhoshk2722
@santhoshk2722 Жыл бұрын
I'm also
@nityamittal6759
@nityamittal6759 Жыл бұрын
Mam can you make a playlist on asymptotic notation pls😃😃😃
@amitkmpbtup
@amitkmpbtup 11 ай бұрын
IT DOESNT WORK WHEN U DO THE HANGMAN STGES IT IS SHOWING OUT OF INDEX WHEN I RUN IT PLS HELP
@ruhulameem1397
@ruhulameem1397 Жыл бұрын
Hello mam mam please make video on numpy, matplotlib, and pandas library of python because i am preparing as a data analytics and these library is necessary for being data analytics ur concept and way of teaching is very elegant and fabulous i learn data structures from your tutorial and suggest my junior to watch your video of DSA please mam make video on these library tl thank you
@-SakuraNoHana-
@-SakuraNoHana- Ай бұрын
Hello ma'am, Can you please make a video on python import time? I would really appreciate it. Thank you!
@Shashank1703
@Shashank1703 Жыл бұрын
Mam Do one video on Java Programming Basics
@ObulshettySrikari
@ObulshettySrikari 9 ай бұрын
Mam instead of making an empty list can we write for i in chosen_list: print("_", end=" ") Will we get blanks mam??
@user-wb2kf5mt1u
@user-wb2kf5mt1u 8 ай бұрын
display = ['_']*len(chosen_word) #This will do your job
@omkarmurala2084
@omkarmurala2084 Жыл бұрын
Like u said we can make this hangman game in multiple ways can u please elaborate so that we can understand
@rahim...writeschannel2.3k14
@rahim...writeschannel2.3k14 Жыл бұрын
💞👍👍👍
@Lucky_truth
@Lucky_truth 9 ай бұрын
import random print("WELCOME TO HANGMAN") heart=6 won=False list1= ["lamp", "chair", "book", "spoon", "tree", "hat", "bike", "door", "pen", "cup", "shoe", "clock", "ball", "table", "sun", "moon", "flower", "bridge", "cloud", "pillow"] # random words word=random.choice(list1)#choose a random word from the list word=list(word)#make it in to list again output = ["_"] * len(word) print(output) while heart: guess=input("Guess a letter") for i in range(len(word)): if(guess==word[i]): output[i]=guess print(output) if(output==word): won=True print("you won!") if (guess not in word): heart -= 1 print(f"You have {heart} heart left") if(won==True): break if(heart==0): print(f"The word is {word}")
@harshachaukyareddy1341
@harshachaukyareddy1341 7 ай бұрын
Excellent..💫
@vaibhavichanne6666
@vaibhavichanne6666 7 ай бұрын
guess=input("Guess a letter").lower()
@jjjmemes420
@jjjmemes420 Ай бұрын
Super bro..... ❤❤
@user-em8qb4gp8y
@user-em8qb4gp8y Жыл бұрын
In the program of hangman game you have not defined lives. Your program is not showing name error for lives but mine is showing name error. please clear it mam
@mirunalini.m1561
@mirunalini.m1561 Жыл бұрын
I have a doubt mam. In C program (file handling) how to print a specified line of the file . Could u plz upload a video on this. I tried it but only if I give 0 as input it shows the output (not correct line .it prints last one)
@Shivayanamah21
@Shivayanamah21 Жыл бұрын
int lineNumber = 8; static const char filename[] = "Text.txt"; FILE *file = fopen(filename, "r"); int count = 0; if ( file != NULL ) { char line[256]; /* or other suitable maximum line size */ while (fgets(line, sizeof line, file) != NULL) /* read a line */ { if (count == lineNumber) { //use line or in a function return it //in case of a return first close the file with "fclose(file);" } else { count++; } } fclose(file); }
@TSHILIDZI_MUNYAI
@TSHILIDZI_MUNYAI 10 ай бұрын
How to u code the figure? The hangman stages that u just imported
@ChildhoodForever1808
@ChildhoodForever1808 Жыл бұрын
Ma'am I am currently in 1st year of btech and I want to prepare for gate. When do you think I should start preparing for it please tell me 🙏
@rauhan_sheikh
@rauhan_sheikh 11 ай бұрын
for the 1st 2-3 years focus on learning and building projects and also do internship in the 3rd year and based on that decide if you have to or want to do gate or not. if you decide you have better opportunities already because you have built good projects and have proof of work then leave it else if you still want to pursue gate then start. 1 and half year of dedicated preparation is good enough for gate.
@Chandu_SKY
@Chandu_SKY 5 ай бұрын
Hangman module not found error mam
@kirankumar-pv1yy
@kirankumar-pv1yy Жыл бұрын
Mam please Start Java Classes
@RishabhChatterjee-fg2gz
@RishabhChatterjee-fg2gz 11 ай бұрын
Ma'am I'm currently studying in 1st year of diploma in computer science and technology and my dream is to give gate exam and python is my favorite language and I don't want to do any job , I want to be a data scientist professional and want to research about data science field like machine learning, deep learning, artificial intelligence, etc.. I have a question what is big data? and I want to say you to make this course as a professional python developer
@VenkateshAnnabathina
@VenkateshAnnabathina 10 күн бұрын
#need machine learning playlist
@akhil2721
@akhil2721 Жыл бұрын
Mam its a humble request please start c++, I have c++ in my 3 rd sem and currently i am in 2nd sem , so i will need it in 3rd sem .
@braveheart3176RTY
@braveheart3176RTY 3 ай бұрын
hello im rhey from philippines
@systembreaker4864
@systembreaker4864 11 ай бұрын
Mam this has one problem that is if we enter correct letter again in the input it will not take lives it's like we can run this continuously until the whole list of "_" these characters is replaced with letters
@lakshmivaddi4395
@lakshmivaddi4395 Ай бұрын
hello mam,i have a doubt..suppose one word has two or three same letters like example swiss.if we guess a lettter s from word it should placed only one s.. right ?but in our program at a time three 3 S are placed in display..only one letter should be placed by one chance.please clarify my doubt mam
@g.viswnathreddy1869
@g.viswnathreddy1869 Жыл бұрын
Mam ,provide notes in description please 😊😊
@jyoth2009
@jyoth2009 Жыл бұрын
Mam uploaded more and more python videos please
@mzxrex9381
@mzxrex9381 9 ай бұрын
Mam where should i run this code In jupyter notebook or vs code
@Praveen_C11
@Praveen_C11 20 күн бұрын
Vs is better
@narendrakota890
@narendrakota890 Жыл бұрын
Third👍
@NARENDRAPAGOTI
@NARENDRAPAGOTI Жыл бұрын
mam please teach us java too
@yogalakshmipabbisetty5966
@yogalakshmipabbisetty5966 Жыл бұрын
Mam could u plz start java
@ALIENGOATMESSI
@ALIENGOATMESSI Жыл бұрын
here for beauty
@Bodigajohnygoud
@Bodigajohnygoud 9 ай бұрын
mam what if a user enter's a correct word repeatedly??
@burragallaneeraj8136
@burragallaneeraj8136 Жыл бұрын
Please provide code in the description
@bestvideos9088
@bestvideos9088 5 ай бұрын
But how you make hangman_stages?
@abhileswar
@abhileswar 6 ай бұрын
type error = showing cannot concatenate list (not "str") to list , in line display = display + '_' , mam can u explain this problem
@-NChandana-pm9hb
@-NChandana-pm9hb 8 ай бұрын
No module named hangman_stages
@kalyanitamanampudi
@kalyanitamanampudi 4 ай бұрын
Plzz mam start the classes of data science alsoo
@abishakthd6884
@abishakthd6884 Жыл бұрын
I love you 😍 💗 mam
@sharifullahsalarzai
@sharifullahsalarzai Жыл бұрын
Mam please complete c++ videos
@marieswaran8124
@marieswaran8124 10 ай бұрын
Hi Madam, I have doubt in this session, How did you add display variable(list data type) with '_' string. Because those are different data type. Can you provide the answer for this doubt.
@rameshamma6497
@rameshamma6497 9 ай бұрын
The list contains an empty string, we are just concatenation with another string.
@bandikomalkumar8066
@bandikomalkumar8066 Жыл бұрын
What is meant by "Scratch file" which is displayed at top left corner of "Pycharm" application under pythonProject~New~Scratch File. Please 🥺 mam!
@Praveen_C11
@Praveen_C11 20 күн бұрын
Scratch file is just like any other file types like python file or html file or text file. Scratch is the most basic programming language one can learn, usually taught to kids in school. Pycharm has Scratch file as it's default file like how notepad has text file as default, u can change it to python by saving it with .py extension or as text file with .txt extension
@RouMuanNgaihte
@RouMuanNgaihte Жыл бұрын
First
@atmasgamingyt3168
@atmasgamingyt3168 Жыл бұрын
Second
@abishakthd6884
@abishakthd6884 Жыл бұрын
Mam u r so very beautiful
@mattapallichandrashekar8947
@mattapallichandrashekar8947 Жыл бұрын
Mam please start Java play list
@SriRam-in2zv
@SriRam-in2zv 2 ай бұрын
In Python 3.12, it is showing the hangman_stages function is not compatible. Please let me know if there is any other function which can be used in 3.12
@georgevincent93
@georgevincent93 Ай бұрын
it is not an inbuild function it is another python file she created naming "hangman_stages"
@everythingwithanirudha
@everythingwithanirudha Жыл бұрын
mam quality to improve karo, like camera or iphone, or may be the compression is bit high
@lovekushrajput442
@lovekushrajput442 Жыл бұрын
Third😄😄😄😂
@nithinvasamsetti
@nithinvasamsetti Ай бұрын
🥵🥵🥵
@shahiddar9852
@shahiddar9852 Жыл бұрын
Mam can you please send me the details how to make a website I want to make a website
@tech_gaming889
@tech_gaming889 Жыл бұрын
Mam we want emcet online classes
@utkarsh_aa786
@utkarsh_aa786 Жыл бұрын
Maam I am just pass class 12th with( PCM) but ab Samajh nhi aa rha Iska kya 🤔kru?
@vaibhavpatharkar6794
@vaibhavpatharkar6794 11 ай бұрын
Madam iff possible pl use hindi or mixed lang
@gangabankala7745
@gangabankala7745 Жыл бұрын
Madam please make sure send notes in description madam please it's my humble request 😢😢😢
@selamawitbirhanu7298
@selamawitbirhanu7298 7 ай бұрын
thanks mam if you can please send us your source code Thank you
@muneebbolo
@muneebbolo 5 ай бұрын
Here's what each part of the code does: 1. **Imports and Initial Setup** import random import hangman_stages import words_file ``` These lines import the necessary modules for the game. `random` is a built-in Python module for generating random numbers. `hangman_stages` and `words_file` are custom modules that contain the hangman stages and the word list, respectively. 2. **Game Variables** lives=6 chosen_word=random.choice(words_file.words) print(chosen_word) ``` Here, the variable `lives` is set to 6, representing the number of incorrect guesses the player is allowed. `chosen_word` is a randomly selected word from the word list in `words_file`. This word is what the player has to guess. 3. **Display Setup** display=[] for i in range(len(chosen_word)): #0 1 2 3 4 display +='_' print(display) ``` This code creates a list `display` that is used to show the player's progress in guessing the word. It starts as a list of underscores, with one underscore for each letter in `chosen_word`. 4. **Game Loop** while not game_over: letter_guess = input('Guess the letter ').lower() # r for position in range(len(chosen_word)): letter=chosen_word[position] if letter==letter_guess: display[position] = letter_guess print(display) ``` This is the main game loop. The player is asked to guess a letter, which is then checked against each letter in `chosen_word`. If the guessed letter is in the word, the corresponding underscore in `display` is replaced with the letter. 5. **Lives and Game Over Conditions** if letter_guess not in chosen_word: lives -= 1 if lives == 0: game_over = True print('Game Over, You Lose! ') if '_' not in display: game_over = True print('You win!! ') print(hangman_stages.stages[lives]) ``` If the guessed letter is not in the word, the player loses a life. If all lives are lost (`lives == 0`), the game ends and the player loses. If there are no more underscores in `display`, meaning the player has guessed all the letters, the game also ends and the player wins. After each guess, the current hangman stage is printed based on the number of remaining lives.
@adhitya001
@adhitya001 Жыл бұрын
Zero
@wownoob-hp9pp
@wownoob-hp9pp 7 ай бұрын
come to pakistan.
@kirugaming6603
@kirugaming6603 Жыл бұрын
Mam vs code me karo code ko .......
@shaniskshanigamer4085
@shaniskshanigamer4085 Жыл бұрын
Hlo mam
@coding_with_bf
@coding_with_bf Жыл бұрын
Mam 😢
@ravana194
@ravana194 Жыл бұрын
Mam will you marry me 😊😊
@shivaojha6760
@shivaojha6760 Жыл бұрын
Mam I am a student of MITS Gwalior please help me python language
@Arceus948
@Arceus948 Жыл бұрын
Python language is non living thing bruh, how it can help u 😢😢😭😭
@maradanavivek2386
@maradanavivek2386 Жыл бұрын
​@@Arceus948😂😂😂😂
@Rayray-cd3sz
@Rayray-cd3sz Жыл бұрын
# without figure and alternatives which are commented import random list_1 = ["apple", "banana", "cherry", "avocado", "kiwi", "jackfruit"] task_1 = random.choice(list_1) # list_2 = [] print("Guess name of the fruit ! ") #for dash in task_1: #list_2.append("_") # list_2 += "_" hidden_word = ["_"] * len(task_1) # print(hidden_word) is a list of strings print("".join(hidden_word)) # strings joined # print(hidden_word) remains a list of strings attempts = 0 no_of_guesses = 6 guessed_letter = set() while "_" in hidden_word and attempts < no_of_guesses: guess = input("Guess a letter of the word: ") if len(guess) != 1: print("Enter a single letter at a time! ") elif guess in guessed_letter: print("Already guessed, life reduced !") attempts += 1 print(f"{no_of_guesses - attempts} lives remaining") else: guessed_letter.add(guess) if guess in task_1: for i in range(len(task_1)): # for i, letter in enumerate(task_1): if task_1[i] == guess: # if letter == guess and hidden_word[i] == "_": hidden_word[i] = guess # print(hidden_word) print("".join(hidden_word)) else: attempts += 1 print(f"You have {no_of_guesses - attempts} guess left.") if "_" not in hidden_word: print("Congratulation, you have guessed the word") else: print(f"Your chances are over, the correct word is {task_1}")
@georgevincent93
@georgevincent93 Ай бұрын
import random fruits = ["apple", "banana", "orange", "grape", "kiwi", "strawberry", "watermelon", "pineapple", "blueberry", "mango", "pear", "peach", "plum", "cherry", "raspberry", "blackberry", "lemon", "lime", "coconut", "pomegranate", "apricot", "fig", "nectarine", "cranberry", "grapefruit", "tangerine", "lychee", "dragonfruit", "guava", "passionfruit", "melon", "persimmon", "kiwifruit", "cantaloupe", "honeydew", "date", "papaya", "jackfruit", "elderberry", "starfruit", "rhubarb", "boysenberry", "carambola", "kumquat", "soursop", "ackee", "breadfruit", "durian", "longan", "tamarind", "mulberry", "plantain", "quince", "soursop", "uglifruit"] guess=random.choice(fruits) length=len(guess) list1=[] for i in range(length): list1.append("-") print(list1) flag=0 n=0 while('-' in list1 and n!=6): x=input("guess the alphabet ") for i in range(length): if guess[i]==x: flag=1 list1[i]=x if(flag==1): print(list1) print("correct") if(flag==0): n+=1 print(list1) print("incorrect") print(f"you lose {n} life") flag=0 if '-' in list1: print(f"the correct answer was {guess}") print(" you lose the game") else: print(" you win the game")
Functions in Python | Introduction | Python for beginners #lec56
24:07
Jenny's Lectures CS IT
Рет қаралды 118 М.
Python Object Oriented Programming (OOP) - For Beginners
53:06
Tech With Tim
Рет қаралды 3,3 МЛН
Looks realistic #tiktok
00:22
Анастасия Тарасова
Рет қаралды 96 МЛН
1❤️
00:17
Nonomen ノノメン
Рет қаралды 13 МЛН
孩子多的烦恼?#火影忍者 #家庭 #佐助
00:31
火影忍者一家
Рет қаралды 49 МЛН
MEGA BOXES ARE BACK!!!
08:53
Brawl Stars
Рет қаралды 36 МЛН
How to build HANGMAN with Python in 10 MINUTES
9:53
Kite
Рет қаралды 458 М.
Hangman Game for beginners |Introduction | Python Project for beginners #lec53
8:04
015 - INTRODUCTION TO FUNCTIONS IN PYTHON
21:01
Mersthub Mentors
Рет қаралды 5 М.
While Loop in Python | Python Tutorials for Beginners #lec50
26:51
Jenny's Lectures CS IT
Рет қаралды 67 М.
I Made 200 Python Projects...Here Are My 5 FAVORITES
11:23
Tech With Tim
Рет қаралды 142 М.
File Handling in Python | Python Tutorials for Beginners #lec95
45:32
Jenny's Lectures CS IT
Рет қаралды 79 М.
5 Useful F-String Tricks In Python
10:02
Indently
Рет қаралды 274 М.
Looks realistic #tiktok
00:22
Анастасия Тарасова
Рет қаралды 96 МЛН