0% found this document useful (0 votes)
36 views38 pages

Cs Project File

Uploaded by

Vishal Anand
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views38 pages

Cs Project File

Uploaded by

Vishal Anand
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 38

MS DHONI GLOBAL SCHOOL

SF NO: 606/2A&2B, MARUTHI GREEN FIELDS, KASUVAKATTA VILLAGE, HOSUR – 635130

PROJECT REPORT

(2023- 2024)

COMPUTER SCIENCE

TOPIC: HANGMAN GAME

NAME OF THE STUDENT :

REGISTER NUMBER :

CLASS :
MS DHONI GLOBAL SCHOOL

SF NO: 606/2A&2B, MARUTHI GREEN FIELDS, KASUVAKATTA VILLAGE, HOSUR – 635130

CERTIFICATE BY GUIDE

This is to certify that ________________________________________

of Class XII Science, MS DHONI GLOBAL SCHOOL (CBSE), Hosur has

completed his / her project file under my guidance. He / She has taken proper care

and shown utmost sincerity in completing this project.

I certify that this project is up to my expectations and as per the guidelines

issued by CBSE.

Internal Examiner Observer External Examiner

School Seal
ACKNOWLEDGEMENT

Natures teachings need to be there for any success in one’s attempt. Nature, The Almighty,
bestowed blessings on me to reach the goal successfully in this study.
I am privileged to thank Mr. R. Chandrasekar, Chairman, MS DHONI GLOBAL SCHOOL,
Hosur, for his innovating ideas and suggestions given at the time of need in progressing the
task and thus arriving at the goal and for his encouragement by way of his frequent visits to
the place of work.

My profound thanks to Mrs. N. Bhuvaneswari, Correspondent and Senior Principal,


MS DHONI GLOBAL SCHOOL , Hosur for permitting to utilize all the facilities available
in the school to complete the study.

My faithful thanks to Mrs. GAYATHRI , Principal and Management Team, MS DHONI


GLOBAL SCHOOL , Hosur for their support, help in providing facilities and the assistance
extended by them throughout the course of study.

My Hearty and sincere thanks to my guide Mrs. T. Alamelu, CO-ORDINATOR,


Facilitator, Department of Computer Science , MS DHONI GLOBAL SCHOOL, Hosur
for her dynamic guidance, valuable suggestions, tireless encouragement, instrumental
instructions and meticulous corrections in my timely successful completion of the study.

I wish to express my dear thanks to all my Friends for their kind cooperation and
inspiration for the successful completion of this study.

My ever heartful thanks to one and all


INDEX
Chapter Title Pg.no

1 List of figures 1

2 Overview of python 2

3 About python 6

4 Synopsis 9

5 Modules 9

6 Functions 9

7 Requirement of python 10

8 Source code 11

9 Output 29

10 Bibliography 34
LIST OF FIGURES

S.NO Figure Names Pg.no

1 Fig 1 29

2 Fig 2 29

3 Fig 3 30

4 Fig 4 30

5 Fig 5 31

6 Fig 6 31

7 Fig 7 32

8 Fig 8 32

9 Fig 9 33

10 Fig 10 33

1
OVERVIEW OF THE PYTHON LANGUAGE

Python is an interpreted, high-level, general purpose programming


language. Created by Guido van Rossum and first released in 1991,
Python's design philosophy emphasizes code readability with its
notable use of significant whitespace. Its language constructs and
object-oriented approach aim to help programmers write clear,
logical code for small and large-scale projects.

Python is dynamically typed and garbage-collected. It supports


multiple programming paradigms, including procedural, object-
oriented, and functional programming. Python is often described as a
"batteries included" language due to its comprehensive standard
library.

Python was conceived in the late 1980s as a successor to the ABC


language Python 2.0, released in 2000, introduced features like list
comprehensions and a garbage collection system capable of collecting
reference cycles. Python 3.0, released in 2008, was a major revision
of the language that is not completely backward-compatible, and
much Python 2 code does not run unmodified on Python 3.
The Python 2 language, i.e. Python 2.7.x, is "sunsetting" on January 1,
2020 (after extension; first planned for 2015), and the Python team of
volunteers will not fix security issues or improve it in other ways after
that date. With the end-of-life, only Python 3.5.x and later will be
supported.

Python interpreters are available for many operating systems. A global


community of programmers develops and maintains CPython, an open
source reference implementation. A non-profit organization, the Python
Software Foundation, manages and directs resources for Python and
CPython development.

2
PYTHON 3
THE STANDARD TYPE HIERARCHY

None
(Class None Type)

Numbers

Integral Real Complex


(class float) (class complex)

Integer Boolean
(class int) (class bool)

Sequences

Immutable Mutable

Strings Tuples Bytes List Byte arrays

Set Types

Sets Frozen sets


(class set) (class frozen)

Mapping
Dictionaries(class dict)
Callable
Functions, Methods, Classes
Modules

3
PYTHON LIBRARIES

Python's large standard library, commonly cited as one of its greatest


strengths, provides tools suited to many tasks. For Internet-facing
applications, many standard formats and protocols such as MIME
and HTTP are supported. It includes modules for creating graphical
user interfaces, connecting to relational databases, generating
pseudorandom numbers, arithmetic with arbitrary-precision decimals.
manipulating regular expressions, and unit testing.

Some parts of the standard library are covered by specifications (for


example, the Web Server Gateway Interface (WSGI) implementation
follows PEP 333, but most modules are not. They are
specified by their code, internal documentation, and test suites
(if supplied) However, because most of the standard library is cross-
platform Python code, only a few modules need altering or rewriting
for variant implementations.

As of November 2019, the Python Package Index (PyPI), the official


repository for third-party. Python software, contains over 200,000
packages with a wide range of functionality, including:

o Graphical user interfaces


o Web frameworks
o Multimedia
o Databases
o Networking
o Test frameworks Automation
o Web scraping
o Documentation System administration.
o Scientific computing
o Text processing
o Image processing
o Machine learning
4
DEVELOPMENT ENVIRONMENTS

Most Python implementations (including CPython) include a read-eval


print loop (REPL),
permitting them to function as a command line interpreter for which the
user enters statements sequentially and receives results immediately.

Other shells, including IDLE and IPython, add further abilities such as
auto-completion,
session state retention and syntax highlighting.

As well as standard desktop integrated development environments, there


are Web browser-
based IDES; SageMath (intended for developing science and math-related
Python programs); PythonAnywhere, a browser-based IDE and hosting
environment; and Canopy IDE, a
commercial Python IDE emphasizing scientific computing.

5
ABOUT PYTHON

Python is one of those rare languages which can claim to be both simple
and powerful. You
will find yourself pleasantly surprised to see how easy it is to concentrate
on the solution to
the problem rather than the syntax and structure of the language you are
programming in..

The official introduction to Python is:


Python is an easy to learn, powerful programming language. It has efficient
high level data
structures and a simple but effective approach to object-oriented
programming. Python's elegant syntax and dynamic typing, together with
its interpreted nature, make it an ideal language for scripting and rapid
application development in many areas on most platforms.
I will discuss most of these features in more detail in the next section.
Story behind the name:
Guido van Rossum, the creator of the Python language, named the language
after the BBC
show "Monty Python's Flying Circus". He doesn't particularly like snakes
that kill animals
for food by winding their long bodies around them and crushing them.
Features of Python:
 Simple
Python is a simple and minimalistic language. Reading a good Python
program feels almost
like reading English, although very strict English! This pseudo-code nature
of Python is one
of its greatest strengths. It allows you to concentrate on the solution to the
problem rather than
the language itself.
 Easy to Learn
As you will see, Python is extremely easy to get started with. Python has an
extraordinarily
simple syntax, as already mentioned.
6
 Free and Open Source
Python is an example of a FLOSS (Free Libre and Open Source
Software). In simple terms, you can freely distribute copies of this
software, read its source code, make changes to it, and use pieces of
it in new free programs. FLOSS is based on the concept of a
community which shares knowledge. This is one of the reasons why
Python is so good it has been created and is constantly improved by a
community who just want to see a better Python.
 High-level Language
When you write programs in Python, you never need to bother about
the low level details such as managing the memory used by your
program, etc.
 Portable
Due to its open-source nature, Python has been ported to (i.e. changed
to make it work on) many platforms. All your Python programs can
work on any of these platforms without requiring any changes at all if
you are careful enough to avoid any system-dependent features. You
can use Python on GNU/Linux, Windows, FreeBSD, Macintosh,
Solaris. OS/2, Amiga, AROS, AS/400, BeOS, OS/390, z OS, Palm
OS, QNX, VMS, Psion, Acorn RISC OS, VxWorks, PlayStation,
Sharp Zaurus, Windows CE and PocketPC!
You can even use a platform like Kivy to create games for your
computer and for iPhone, iPad, and Android.
 Interpreted
This requires a bit of explanation.
A program written in a compiled language like Cor C++ is converted
from the source language i.e. Cor Cinto a language that is spoken by
your computer (binary code i.e. Os and 1s) using a compiler with
various flags and options. When you run the program, the linker/
loader software copics the program from hard disk to memory and
starts running it.
Python, on the other hand, does not need compilation to binary. You
just run the program directly from the source code. Internally, Python
converts the source code into an intermediate form called bytecodes
and then translates this into the native language of your computer and
then runs it. All this, actually, makes using Python much easier since
7
you don't have to worry about compiling the program, making sure
that the proper libraries are linked and loaded, etc. This also makes
your Python programs much more portable, since you can just copy
your Python, program onto another computer and it just works!
 Object Oriented
Python supports procedure-oriented programming as well as object-
oriented programming. In procedure-oriented languages, the program
is built around procedures or functions which are nothing but reusable
pieces of programs. In object-oriented languages, the program is built
around objects which combine data and functionality. Python has a
very powerful but simplistic way of doing OOP, especially when compared
to big languages like C++ or Java.
 Extensible
If you need a critical piece of code to run very fast or want to have
some piece of algorithm not to be open, you can code that part of your
program in Cor C++ and then use it from your Python program.
 Embeddable
You can embed Python within your C/C++ programs to give scripting
capabilities for your program's users
Extensive Libraries
The Python Standard Library is huge indeed. It can help you do various
things involving regular expressions, documentation generation, unit
testing, threading, databases, web browsers, CGI, FTP, email, XML,
XML-RPC, HTML, WAV files, cryptography. GUI (graphical user
interfaces), and other system-dependent stuff. Remember, all this is
always available wherever Python is installed. This is called the
Batteries Included philosophy of Python. Besides the standard library,
there are various other high-quality libraries which you can find at the
Python Package Index.

Summary:
Python is indeed an exciting and powerful language. It has the right
combination of performance and features that make writing programs
in Python both fun and easy.

8
SYNOPSIS

Specially defined functions in the project:

1.random()-Helps generate random values

Built in functions in project:

1.tuple()-Helps convert actual parameters to a tuple.

2.count()-Helps count the number of terms in the parameter.

3.index()-Helps find the index positon of the term in the parameter.

4.return()-Helps return a value in function.

5. input() - Helps print a value.

6.input()-Helps input a value from the user.

7.index()-Helps find the index positon of the term in the parameter.

8. ______.append()- Helps add a term at the end of the parameter tuple.

9. _______.remove()-Helps remove a term from the parameter tuple.

10. ______.join()-Helps join the terms to the parameter tuple.

9
REQUIREMENTS FOR PYTHON HARDWRE
REQUIREMENTS

 1 GB RAM (2 GB+ Recommended)

 9-58 GB free hard disk space depending on edition and configuration,

including space required for temporary filest

 DVD-ROM drive (if installing from a Media Kit DVD)

 Basic GPU-Any vendor DirectX 9.0 class or better (Pixel Shader Level 2)

 Intel Pentium or Compatible, 1.6 GHz minimum (2 GHz+ recommended)

 1024 x 768 or higher-resolution monitor

 Mouse or other pointing device

SOFTWARE REQUIREMENTS:

 Microsoft Windows 10 (32-bit and 64-bit)

 Code Blocks

10
Source Code:

word list = [
'wares',
'soup',
mount,
'extend',
brown',
'expert',
'tired’,
humidity,
'backpack',
crust',
'dent',
'market',
'knock',
'smite',
'windy',
'coin',
'throw',
'silence',
'bluff',
'downfall',
'climb',
lying',
'weaver',
'snob',
‘kickoff’,
'match',
'quaker',
'foreman',
'excite',
'thinking",
'mend',

11
'allergen',
'pruning',
'coat',
'emerald',
'coherent',
'manic',
'multiple',
'square',
'funded',
'funnel',
'sailing',
'dream',
'mutation',
'mystic',
'film',
'guide',
'strain',
'bishop',
'settle',
'plateau',
'emigrate',
'marching',
'optimal',
'medley',
'endanger',
'wick',
'condone',
'schema',
'rage',
'figure',
'plague',
'aloof’,

12
'there',
'reusable',
'refinery'.
'suffer',
'affirm',
'captive',
'flipping',
'prolong',
'main',
'coral',
'dinner',
'rabbit',
'chill',
'seed',
'born',
'shampoo',
'italian',
'giggle',
'roost',
'palm',
'globe',
'wise',
'grandson',
'running',
'sunlight',
'spending',
'tangle',
'forego',
'tailor',
'divinity',
'probe',
'bearded',

13
'premium',
'featured',
'serve',
'borrower',
'examine',
'legal',
'outlive',
'unnamed',
'unending',
'snow',
'whisper'.
'bundle',
'bracket',
'deny',
'blurred',
'pentagon',
'reformed',
'polarity',
'jumping',
'gain',
'laundry',
'hobble',
'culture',
'whittle',
'mayhem',
'build',
'peel',
'board',
'keen',
'glorious',
'singular',
'cavalry',

14
'present',
'cold',
'hook',
'salted',
'just',
'dumpling',
'glimmer',
'drowning',
'admiral',
'sketch',
'subject',
'upright',
'sunshine',
'slide',
'calamity',
'gurney',
'adult',
'adore',
'weld',
'masking',
'print',
'wishful',
'foyer',
'machete',
'diced',
'behemoth',
'rout',
'midwife',
'neglect',
'mass',
'game',
'stocking',

15
'folly',
'action',
'bubbling',
'scented',
'sprinter',
'bingo',
'egyptian',
'comedy',
'rung',
'outdated',
'radical',
'escalate',
'mutter',
'desert',
'memento',
'kayak',
'talon'.
'portion',
'affirm',
'dashing',
'battle',
'pupil',
'rite',
'smash',
'true',
'entrance',
'counting',
'peruse',
'dioxide',
'hermit',
'carving',
'backyard',

16
'homeless',
'medley',
'packet',
'tickle',
'coming',
'leave',
'swing',
'thicket',
'reserve',
'murder',
'costly',
'corduroy',
'bump',
'oncology',
'swatch',
'rundown',
'steal',
'teller',
'cable',
'official',
'abyss',
'schism',
'failing',
'guru',
'trim',
'alfalfa',
'doubt',
'booming',
'bruised',
'playful',
'kicker',
'jockey',

17
‘handmade’,
‘landfall’,
‘rhythm',
‘keep',
‘reassure',
‘garland’,
‘sauna',
‘idiom',
'fluent',
‘lope',
'gland',
"amend',
'fashion',
'treaty’,
'standing',
'current',
'sharpen',
'cinder',
'idealist',
festive',
'frame',
'sill’,
'glisten',
'fearful',
‘basement’,
'minutia",
'coin',
'stick',
‘featured’,
‘soot',
'static',
‘crazed’,

18
'upset',
'robotics',
'dwarf',
'shield',
'butler',
'stitch',
'stub',
'sabotage',
'parlor',
'prompt',
'heady',
'horn',
'rework',
'painful',
'composer',
'glance',
'acquit',
'eagle',
'solvent',
'backbone',
'smart',
'atlas',
'leap',
'danger',
'bruise',
'seminar',
'tinge',
'trip',
'narrow',
'while',
'jaguar',
'seminary',

19
'command',
'cassette',
'draw',
'anchovy',
'scream',
'blush',
'organic',
'applause',
'parallel',
'trolley',
'pathos',
'origin',
'hang',
'pungent',
'angular',
'stubble',
'painted',
'forward',
'saddle',
'orchid',
'prudence',
'disprove',
'yiddish',
'lobbying',
'neuron',
'tumor',
'haitian',
'swift',
'mantel',
'wardrobe',
'consist',
'storied',

20
'extreme',
'payback',
'control',
'dummy',
'influx',
'realtor',
'detach',
'flake',
'consign',
'adjunct',
'stylized',
'weep',
'prepare',
'pioneer',
'platoon',
'exercise',
'dummy',
'clap',
'actor',
'spark',
'dope',
'phrase',
'welsh',
'wall',
'whine',
'fickle',
'wrong',
'stamina',
'dazed',
'cramp',
'filet',
'foresee',

21
'seller',
'award',
'mare',
'uncover',
'drowning',
'ease',
'buttery',
'luxury'.
'bigotry',
'muddy',
'photon',
'snow',
'blessed',
'call',
'stain',
'amber'.
'rental',
'nominee',
'township',
'adhesive',
'lengthy',
'swarm',
'court',
'baguette',
'leper',
'vital',
'push',
'digger',
'setback',
'accused',
'taker',
'genie',

22
'reverse',
'fake',
'widowed',
'renewed',
'goodness',
'featured',
'curse',
'shocked',
'shove',
'marked',
'interact',
'mane',
'hawk',
'noble',
'proton',
'effort',
'patriot',
'showcase',
'parish',
'mosaic',
'coil',
'aide',
'breeder',
'concoct',
'pathway',
'hearing',
'bayou',
'regimen',
'drain',
'bereft',
'matte',
'bill',

23
'medal',
'prickly',
'sarcasm',
'stuffy',
'allege',
'monopoly',
'lighter',
'repair',
'worship'.
'vent',
'hybrid',
'buffet',
'lively']
import random
def get word():
word random.choice(word list)
return word.upper()
def play(word):
word completion="" len(word)
guessed = False
guessed letters [
guessed words=[]
tries = 6
print("Let's play Hangman!")
print(display hangman(tries))
print(word_completion)
print("\n")
while not guessed and tries 0:
guess = input("Please guess a letter. ").upper()
if len(guess) I and guess.isalpha():
if guess in guessed letters:

24
print("You already guessed the letter", guess)
elif guess not in word:
print(guess, "is not in the word.")
tries=- 1
guessed letters.append(guess)
else:
print("Good job.", guess, "is in the word!")
guessed letters.append(guess)
word_as listlist(word_completion)
indices [i for i, letter in enumerate(word) if letter
==guess]
for index in indices:
word as list[index] = guess
word_completion = "".join(word_as_list)
if "_" not in word_completion:
guessed = True
elif len(guess) == len(word) and guess.isalpha():
if guess in guessed words:
print("You already guessed the word", guess)
elif guess != word:
print(guess, "is not the word.")
tries=-1
guessed_words.append(guess)
else:
guessed = True
word_completion = word
else:
print("Not a valid guess.")
print(display_hangman(tries))
print(word_completion)
print("\n")
if guessed:
print("Congrats, you guessed the word! You win!")

25
else:
print("Sorry, you ran out of tries. The word was " + word +". Maybe
next time!")

def display hangman(tries):


stages [# final state: head, torso, both arms, and both legs
“““
------------
| |
| O
| \|/
| |
| /\
”””,
#head, torso, both arms, and one leg
“““
------------
| |
| O
| \|/
| |
| /
”””,

#head, torso, and both arms


“““
------------
| |
| O
| \|/
| |
|
”””,

26
#head, torso, and one arm
“““
------------
| |
| O
| \|
| |
|
”””,

#head and torso


“““
------------
| |
| O
| |
| |
|
”””,

# head
“““
------------
| |
| O
|
|
|
”””,

27
# initial empty state
“““
------------
| |
|
|
|
|
”””

]
return stages[tries]
def main():
word = get_word()
play(word)
while input("Play Again? (Y/N)").upper()- "Y":
word = get_word() play(word)
if __name__ == “__main__”:
main()

28
Output 1:

Fig 1

Fig 2
29
Fig 3

Fig 4
30
Fig 5

Output 2:

Fig 6

31
Fig 7

Fig 8
32
Fig 9

Fig 10
33
BIBLIOGRAPHY

 www.google.com
 www.geeksforgeeks.org
 www.codecademy.com
 www.w3schools.com
 www.youtube.com
 www.wikepedia.com
 Computer Science with Python by Sumita Arora

34

You might also like