Ghost Prank in Python | Source Code | Live Practical

   Step by Step Procedure to create Ghost Prank in Python

Hello friends how are you, Today in this post "Ghost Prank in Python" i am going to teach you how you can create a Ghost Prank in Python using few lines of code. If you want to create something interesting in programming using Python code then this post is for you. you can also surprise your friend by using this scary project

Now  i am going to explain it step by step so just go through this post to understand this completely.

If you want to understand this through video then watch this video i have explained it step by step live

Step 1: Install Python : Click here to watch a video on how to install python or Open any browser and type Download Python and click the first link you will get official website of python here you will get a Download button and after clicking on this button you will get exe of latest python version just install it into your system. 

Step 2: Install Pycharm | Create Project | Install LibraryClick here to watch a single video on How to install Pycharm | Create Project | Install Library  or To install Pycharm IDE Open any browser and type Download Pycharm and click the first link you will get official website of Pycharm  here you will get a black download button and after clicking on this button you will get an exe of Pycharm , just install it into your system. If you are facing problem to install then watch the above video i have explained step by step.

Step 3: Create Project : Open Pycharm  click on File which is in top left of screen and select New Project. Then you will get a screen. Here first you need to select directory of your project and then type a name for your project like "GhostPrank" after directory name, and at last click the create button to create this project. 

Step 4: Create Python file: To create a python file for coding in your project just right click on project name "GhostPrank" and select new and click on Python File , you will get popup screen in which you have to type a name like "Program" for python file and press enter, it will create a python file with name Program.py inside the project GhostPrank. 

Step 5: Store image and Music files: Here in this program i am using two music files one(sound.mp3) for background and another(screaming.mp3) for ghost screaming. I am also using one image(ghost.jpg) for showing ghost here so first  download the music that you want to play and an image that you want to display and then just place these music files and image inside the folder/project folder where python file exists.

Step 6:Python code:  Here is the complete code for this project/program you just need to type this code into your python file or you can copy this code for your personal use.

#import libraries
from pygame import  mixer
import pygame as pg
import  time
#initialize pygame
pg.init()
#creating window
window=pg.display.set_mode((0,0),pg.FULLSCREEN)
#intializing mixer
mixer.init()
#load backgroung music
mixer.music.load("sound.mp3")
#play background music
mixer.music.play()
#sleep for 5 seconds
time.sleep(5)
#load ghost image
img=pg.image.load("ghost.jpg")
window.blit(img,(150,0))
#load screaming music
mixer.music.load("screaming.mp3")
#play screaming music
mixer.music.play()
pg.display.update()
#sleep for 3 seconds
time.sleep(3)

Just copy this code from here and paste it into program.py .


Step 7: Run Code: To run this code just right click on the coding area and click on Run Program and you will get a output screen like below. Just play the below video
I hope now you can  create "Ghost Prank in Python". If you have any doubt regarding this post  or you want something more in this post then let me know by comment below i will work on it definitely.
 

Request:-If you found this post helpful then let me know by your comment and share it with your friend. 
 
If you want to ask a question or want to suggest then type your question or suggestion in comment box so that we could do something new for you all. 

If you have not subscribed my website then please subscribe my website. Try to learn something new and teach something new to other. 

If you like my post then share it with your friends. Thanks😊Happy Coding.



Post a Comment

1 Comments