Posts

Showing posts from March, 2024

File manager

                 Welcome to file manager. This is file manager code you can file create, edit, read, delete.  import os module. import os def create_file (filename): with open (filename, 'w' ) as file: print ( "File created:" , filename) def read_file (filename): try : with open (filename, 'r' ) as file: print ( "Content of" , filename, ":" ) print (file.read()) except FileNotFoundError : print ( "File not found." ) def update_file (filename): try : with open (filename, 'a' ) as file: text = input ( "Enter text to append: " ) file.write(text + " \n " ) print ( "Text appended to" , filename) except FileNotFoundError : print ( "File not found." ) def delete_file (filename): try : os.remove(filename) print ( "File deleted:" , filename) ...

Screen Recording using python.

        Welcome to Screen recording code. This is screen recording code. You can use this code firstly import these modules like :- cv2, numpy, and pyautogui.   you can exit this screen recording   press    ' q '. file name is ' screen_recording.avi '.     import pyautogui import cv2 import numpy as np screen_size = pyautogui.size() fourcc = cv2.VideoWriter_fourcc(* "XVID" ) out = cv2.VideoWriter( "screen_recording.avi" , fourcc, 20.0 , screen_size) try : while True : screenshot = pyautogui.screenshot() frame = np.array(screenshot) frame = cv2.cvtColor(frame, cv2.COLOR_RGB2BGR) out.write(frame) # Break the loop on 'q' key press if cv2.waitKey( 1 ) & 0xFF == ord ( 'q' ): break except KeyboardInterrupt : pass out.release() cv2.destroyAllWindows()

Make heart using python.

          Welcome to Heat making in python.                      This is heat making code using python. You can start import turtle module. import turtle screen = turtle.Screen() screen.setup( width = 600 , height = 600 ) screen.bgcolor( 'white' ) pen=turtle.Turtle() pen.speed( 'fastest' ) pen.color( 'red' ) pen.begin_fill() pen.penup() pen.goto(- 50 ,- 150 ) pen.pendown() pen.left( 130 ) pen.forward( 200 ) for _ in range ( 190 ): pen.right( 1 ) pen.forward( 2 ) pen.left( 120 ) for _ in range ( 190 ): pen.right( 1 ) pen.forward( 2 ) pen.forward( 289 ) pen.right( 100 ) pen.forward( 93 ) pen.end_fill() pen.hideturtle() turtle.exitonclick()

Make ' S ' using turtle in python.

                Welcome to ' S ' make turtle.                  This is making ' S ' using turtle in python. import turtle # Create a turtle object t = turtle.Turtle() # Set fill color t.fillcolor( "red" ) # Move the turtle to the starting point t.penup() t.goto(- 100 , 0 ) t.pendown() # Begin filling t.begin_fill() # Draw the S t.forward( 40 ) t.circle( 43 , 180 ) t.circle(- 50 , 180 ) t.forward( 40 ) t.penup() t.goto(- 100 , 0 ) t.pendown() t.right( 90 ) t.forward( 15 ) t.left( 90 ) t.forward( 40 ) t.circle( 57 , 180 ) t.circle(- 35 , 180 ) t.forward( 40 ) t.left( 90 ) t.forward( 17.5 ) # End filling t.end_fill() # Hide the turtle t.hideturtle() # Keep the window open until it is manually closed turtle.done()

Digital clock.

                           Welcome to digital clock code. This is Digital clock code you can impot pyQt5 module. # importing libraries from PyQt5.QtWidgets import * from PyQt5 import QtCore, QtGui from PyQt5.QtGui import * from PyQt5.QtCore import * import sys # creating a clock class class Clock(QMainWindow): # constructor def __init__ ( self ): super (). __init__ () # creating a timer object timer = QTimer( self ) # adding action to the timer # update the whole code timer.timeout.connect( self .update) # setting start time of timer i.e 1 second timer.start( 1000 ) # setting window title self .setWindowTitle( 'Clock' ) # setting window geometry self .setGeometry( 200 , 200 , 300 , 300 ) # setting background color to the window self .setStyleSheet( "background : black;" ) # creating hour hand self .h...

Webcam open.

                       Welcome to webcam open code. This is webcam open code. ### webcam import cv2 # Open webcam # Your webcam not open then you will try 0 or 1 or 2 cap = cv2.VideoCapture( 1 ) # 1 is my by default 0 # Check if the webcam is opened correctly if not cap.isOpened(): print ( "Error: Could not open webcam." ) exit () # Loop to continuously capture frames from the webcam while True : # Capture frame-by-frame ret, frame = cap.read() # Display the captured frame cv2.imshow( 'Webcam' , frame) # Wait for 'q' key to exit the loop if cv2.waitKey( 1 ) & 0xFF == ord ( 'q' ): break # Release the webcam and close all OpenCV windows cap.release() cv2.destroyAllWindows()

Web Brower open

               Welcome to Web Brower open code. This is web Brower open code. you can change the website then you change the URL. import webbrowser def Game_open (): #You can change the url but make sure you pasate the url inside " " url = "https://www.crazygames.com/game/wrestle-bros" webbrowser.open(url) # Example usage: Game_open()

Snake, Water, Gun Game.

                    Welcome to Snake, Water, Gun game. This is snake, water, gun game you can design your own. import random def get_computer_choice (): choices = [ "snake" , "water" , "gun" ] return random.choice(choices) def get_user_choice (): while True : user_choice = input ( "Enter your choice (snake, water, gun): " ).lower() if user_choice in [ "snake" , "water" , "gun" ]: return user_choice else : print ( " \n Invalid choice! Please enter either snake, water, or gun. \n " ) def determine_winner (user_choice, computer_choice): if user_choice == computer_choice: return "draw" elif user_choice == "snake" : return "win" if computer_choice == "water" else "loss" elif user_choice == "water" : return "win" if computer_choice == "gun"...

Password Generator

        Welcome to password Generator Code This is password generator code. You can set the length of password. import random import string def generate_password (length= 12 ): characters = string.ascii_letters + string.digits + string.punctuation password = '' .join(random.choice(characters) for _ in range (length)) return password if __name__ == "__main__" : length = int ( input ( "Enter the length of the password: " )) password = generate_password(length) print ( "Generated Password:" , password)

Palindrome word checker.

          Welcome to palindrome word checker This is checking user input the word it is palindrome or not. Palindrome mean=> word right to left or left to right is same word Ex=> Nitin, Oo, Level, etc. a= str ( input ( "Enter the palindrome:" )) b=a[::- 1 ] if a.lower()==b.lower(): print ( "This is palindrome" ) else : print ( "This is not palindrome" )

Vowel Count.

                      Welcome vowel count code               This is vowel count code. It is user input then user give value they find the vowel. Input= input ( "Enter your vowels word:" ) vowels= "aeiouAEIOU" Output= 0 for Vow in Input: if Vow.lower() in vowels: Output += 1 print ( "The total vowel words are" ,Output)

Web site open

                                Welcome to website open code               This is website open code you can change the URL then website is change.  You can change the name like - Game_open   you can change the - - open. import webbrowser def Game_open (): url = "https://www.crazygames.com/game/wrestle-bros" webbrowser.open(url) # Example usage: Game_open()

ATM Code

                                            Welcome to ATM code.                    This is ATM make only Python you can customize the ATM code.         This ATM already 4 accounts created you can add your account. The 4 accounts details. 1. Name =Shivam, Azad, Rama, Name 2. Pin =6196,8750,.9310,1234 3. Amount=10000000,20000,5,1650 It is line vise, Ex-Name=Shivam, Pin=6196, Amount=10000000 print ( "WELCOME TO SBI ATM \n " ) users_name=[ 'SHIVAM' , 'AZAD' , 'RAMA' , 'NAME' ] amounts=[ 1000000000 , 20000 , 5 , 1650 ] pins=[ 6196 , 8750 , 9310 , 1234 ] def create_account (): name = input ( "Enter your name: " ) if name.upper() in users_name: print ( "Account already exists. Please choose a different name." ) return None , None else : amount = float ( input ( "Enter initial bal...