en
Feedback
Coding_knowledge

Coding_knowledge

Open in Telegram

💡 Your Coding Journey Starts Here! Get free courses, coding resources, internships, job updates & much more. Stay ahead in tech with us! ❤️🚀 Join our WhatsApp group👇 https://whatsapp.com/channel/0029Vaa7CVhCRs1rxJzy1n3D

Show more

📈 Analytical overview of Telegram channel Coding_knowledge

Channel Coding_knowledge (@coding_knwledge01) in the English language segment is an active participant. Currently, the community unites 79 382 subscribers, ranking 1 561 in the Technologies & Applications category and 3 823 in the India region.

📊 Audience metrics and dynamics

Since its creation on невідомо, the project has demonstrated rapid growth, gathering an audience of 79 382 subscribers.

According to the latest data from 02 September, 2026, the channel demonstrates stable activity. Although there has been a change in the number of participants by -850 over the last 30 days and by -12 over the last 24 hours, overall reach remains high.

  • Verification status: Not verified
  • Engagement rate (ER): The average audience engagement rate is 9.91%. Within the first 24 hours after publication, content typically collects 2.57% reactions from the total number of subscribers.
  • Post reach: On average, each post receives 7 865 views. Within the first day, a publication typically gains 2 040 views.
  • Reactions and interaction: The audience actively supports content: the average number of reactions per post is 19.
  • Thematic interests: Content is focused on key topics such as q&a, goody, api, stack, analyst.

📝 Description and content policy

The author describes the resource as a platform for expressing subjective opinions:
💡 Your Coding Journey Starts Here! Get free courses, coding resources, internships, job updates & much more. Stay ahead in tech with us! ❤️🚀 Join our WhatsApp group👇 https://whatsapp.com/channel/0029Vaa7CVhCRs1rxJzy1n3D

Thanks to the high frequency of updates (latest data received on 03 September, 2026), the channel maintains relevance and a high level of publication reach. Analytics show that the audience actively interacts with content, making it an important point of influence in the Technologies & Applications category.

79 382
Subscribers
-1224 hours
-1677 days
-85030 days
Posts Archive
HR Interview Asked in Software & Data roles .pdf9.94 KB

Output
Output

Code :- import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; public class CalendarApplication extends JFrame { private List<Event> events = new ArrayList<>(); private JList<Event> eventList; private DefaultListModel<Event> listModel; private JButton addButton, editButton, deleteButton; public static void main(String[] args) { SwingUtilities.invokeLater(() -> new CalendarApplication().setVisible(true)); } public CalendarApplication() { setTitle("Calendar Application"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(800, 600); initComponents(); } private void initComponents() { listModel = new DefaultListModel<>(); eventList = new JList<>(listModel); addButton = new JButton("Add Event"); editButton = new JButton("Edit Event"); deleteButton = new JButton("Delete Event"); setLayout(new BorderLayout()); JPanel controlPanel = new JPanel(new FlowLayout()); controlPanel.add(addButton); controlPanel.add(editButton); controlPanel.add(deleteButton); add(new JScrollPane(eventList), BorderLayout.CENTER); add(controlPanel, BorderLayout.SOUTH); addButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Event newEvent = createNewEvent(); if (newEvent != null) { events.add(newEvent); updateEventList(); } } }); editButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Event selectedEvent = eventList.getSelectedValue(); if (selectedEvent != null) { editEvent(selectedEvent); updateEventList(); } } }); deleteButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Event selectedEvent = eventList.getSelectedValue(); if (selectedEvent != null) { events.remove(selectedEvent); updateEventList(); } } }); } private Event createNewEvent() { String name = JOptionPane.showInputDialog(this, "Enter event name:"); if (name != null && !name.trim().isEmpty()) { String dateStr = JOptionPane.showInputDialog(this, "Enter event date (yyyy-MM-dd):"); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); try { Date date = dateFormat.parse(dateStr); return new Event(name, date); } catch (Exception e) { JOptionPane.showMessageDialog(this, "Invalid date format. Event not added."); } } return null; } private void editEvent(Event event) { String newName = JOptionPane.showInputDialog(this, "Enter new event name:", event.getName()); if (newName != null && !newName.trim().isEmpty()) { String newDateStr = JOptionPane.showInputDialog(this, "Enter new event date (yyyy-MM-dd):", event.getDateStr()); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); try { Date newDate = dateFormat.parse(newDateStr); event.setName(newName); event.setDate(newDate); } catch (Exception e) { JOptionPane.showMessageDialog(this, "Invalid date format. Event not edited."); } } } private void updateEventList() { listModel.clear(); for (Event event : events) {

Calendar Application using Java Swing Introduction: The Calendar Application is a user-friendly desktop application built using Java Swing that allows users to manage their events and appointments efficiently. The application provides an interactive graphical interface for adding, editing, and deleting events, along with a clear display of scheduled events in a list. With its intuitive design, the Calendar Application simplifies event management and scheduling for users. Key Features: Event Management: Users can easily create, edit, and delete events through a user-friendly interface. The application provides dialogs for entering event names and dates, making it simple to schedule appointments, meetings, or reminders. Visual Representation: The application uses a graphical interface to display events in a list format. Users can quickly scan their scheduled events and identify important dates. Date Format Validation: The application ensures that dates entered by users adhere to the specified format (yyyy-MM-dd). It displays error messages if the date format is incorrect, enhancing the user experience. Single Selection: The application uses a JList component to allow users to select a single event at a time for editing or deletion. This prevents confusion and provides a clear focus on the selected event. Data Persistence: Although not included in the provided code, you can extend the application to save events to a file or database for data persistence between sessions. User Interaction: The application provides buttons for adding, editing, and deleting events, making it easy for users to perform common actions. Dialogs guide users through the event creation and editing process. Error Handling: The application includes error handling mechanisms to provide feedback to users when incorrect data formats are entered or when errors occur during event creation or editing. Simple User Interface: The application’s straightforward user interface enables users to quickly understand and interact with the features. It is designed to minimize clutter and provide a clean experience. Flexibility: Users can customize event names and dates according to their needs, allowing them to manage a variety of appointments, tasks, and engagements. Easy Deployment: The application is built using Java Swing, a standard Java library, ensuring that it can be easily compiled and run on various platforms without requiring extensive setup.

Output
Output

# import required packages from tkinter import * # variable to store the user entered expression exp='' # Function to store the values entered by user (numbers and operators) def press(number): global exp exp+=str(number) equation.set(exp) def equalpress(): try: global exp # eval to evaluate the expression total = str(eval(exp)) equation.set(total) # initialize the expression variable expression = "" except: # display syntax error if we are unable to evaluate user expression equation.set("Syntax error ") exp= "" # Function to clear the entered expression def clear(): global exp exp='' equation.set('') # To create root window tk=Tk() tk.configure(background="grey") tk.title('Calculator by coding_knowladge') tk.geometry('280x280') # To store the values entered by the user equation=StringVar() # Entry Box to accept the user’s expression(input) Text_Entry_Box=Entry(tk,textvariable=equation,width=20) Text_Entry_Box.grid(columnspan=8,ipadx=100) button1 = Button(tk, text=' 1 ', fg='black', bg='#8f8f8f',command=lambda: press(1), height=2, width=7) button1.grid(row=2, column=0) button2 = Button(tk, text=' 2 ', fg='black', bg='#8f8f8f',command=lambda: press(2), height=2, width=7) button2.grid(row=2, column=1) button3 = Button(tk, text=' 3 ', fg='black', bg='#8f8f8f',command=lambda: press(3), height=2, width=7) button3.grid(row=2, column=2) button4 = Button(tk, text=' 4 ', fg='black', bg='#8f8f8f',command=lambda: press(4), height=2, width=7) button4.grid(row=3, column=0) button5 = Button(tk, text=' 5 ', fg='black', bg='#8f8f8f',command=lambda: press(5), height=2, width=7) button5.grid(row=3, column=1) button6 = Button(tk, text=' 6 ', fg='black', bg='#8f8f8f',command=lambda: press(6), height=2, width=7) button6.grid(row=3, column=2) button7 = Button(tk, text=' 7 ', fg='black', bg='#8f8f8f',command=lambda: press(7), height=2, width=7) button7.grid(row=4, column=0) button8 = Button(tk, text=' 8 ', fg='black', bg='#8f8f8f',command=lambda: press(8), height=2, width=7) button8.grid(row=4, column=1) button9 = Button(tk, text=' 9 ', fg='black', bg='#8f8f8f',command=lambda: press(9), height=2, width=7) button9.grid(row=4, column=2) button0 = Button(tk, text=' 0 ', fg='black', bg='#8f8f8f',command=lambda: press(0), height=2, width=7) button0.grid(row=5, column=0) plus = Button(tk, text=' + ', fg='black', bg='#8f8f8f',command=lambda: press("+"), height=2, width=7) plus.grid(row=2, column=3) minus = Button(tk, text=' - ', fg='black', bg='#8f8f8f',command=lambda: press("-"), height=2, width=7) minus.grid(row=3, column=3) multiply = Button(tk, text=' * ', fg='black', bg='#8f8f8f',command=lambda: press("*"), height=2, width=7) multiply.grid(row=4, column=3) divide = Button(tk, text=' / ', fg='black', bg='#8f8f8f',command=lambda: press("/"), height=2, width=7) divide.grid(row=5, column=3) equal = Button(tk, text=' = ', fg='black', bg='#8f8f8f',command=equalpress, height=2, width=7) equal.grid(row=5, column=2) clear = Button(tk, text='Clear', fg='black', bg='#8f8f8f',command=clear, height=2, width=7) clear.grid(row=5, column=1) # Run the GUI tk.mainloop()

def add_book(self): book = self.add_book_entry.get() self.books.append(book) messagebox.showinfo("Success", "Book added successfully") self.add_book_entry.delete(0, tk.END) def remove_book(self): book = self.remove_book_entry.get() if book in self.books: self.books.remove(book) messagebox.showinfo("Success", "Book removed successfully") else: messagebox.showerror("Error", "Book not found") self.remove_book_entry.delete(0, tk.END) def issue_book(self): book = self.issue_book_entry.get() if book in self.books: self.lend_list.append(book) self.books.remove(book) messagebox.showinfo("Success", "Book issued successfully") else: messagebox.showerror("Error", "Book not found") self.issue_book_entry.delete(0, tk.END) def view_books(self): message = "\n".join(self.books) messagebox.showinfo("Books", message) if name == "main": root = tk.Tk() app = LibraryManagement(root) root.mainloop()

import tkinter as tk from tkinter import messagebox class LibraryManagement: def init(self, master): self.master = master self.master.title("Library Management System") self.master.geometry("400x400") self.master.config(bg='#708090') self.books = [] self.lend_list = [] # Labels self.login_label = tk.Label(self.master, text="Library Management System", font=("Helvetica", 16), bg='#708090', fg='white') self.login_label.pack() self.username_label = tk.Label(self.master, text="Username", font=("Helvetica", 12), bg='#708090', fg='white') self.username_label.pack() self.username_entry = tk.Entry(self.master, font=("Helvetica", 12)) self.username_entry.pack() self.password_label = tk.Label(self.master, text="Password", font=("Helvetica", 12), bg='#708090', fg='white') self.password_label.pack() self.password_entry = tk.Entry(self.master, font=("Helvetica", 12), show="*") self.password_entry.pack() # Login self.login_button = tk.Button(self.master, text="Login", command=self.login, font=("Helvetica", 12)) self.login_button.pack() # Register self.register_button = tk.Button(self.master, text="Register", command=self.register, font=("Helvetica", 12)) self.register_button.pack() self.username = "" self.password = "" self.librarians = [] def login(self): self.username = self.username_entry.get() self.password = self.password_entry.get() for librarian in self.librarians: if self.username == librarian[0] and self.password == librarian[1]: self.username_entry.delete(0, tk.END) self.password_entry.delete(0, tk.END) self.login_label.destroy() self.username_label.destroy() self.username_entry.destroy() self.password_label.destroy() self.password_entry.destroy() self.login_button.destroy() self.register_button.destroy() self.library_management_screen() return messagebox.showerror("Error", "Invalid username or password") def register(self): self.username = self.username_entry.get() self.password = self.password_entry.get() self.librarians.append([self.username, self.password]) self.username_entry.delete(0, tk.END) self.password_entry.delete(0, tk.END) def library_management_screen(self): self.add_book_label = tk.Label(self.master, text="Add Book", font=("Helvetica", 16), bg='#708090', fg='white') self.add_book_label.pack() self.add_book_entry = tk.Entry(self.master, font=("Helvetica", 12)) self.add_book_entry.pack() self.add_book_button = tk.Button(self.master, text="Add Book", command=self.add_book, font=("Helvetica", 12)) self.add_book_button.pack() self.remove_book_label = tk.Label(self.master, text="Remove Book", font=("Helvetica", 16), bg='#708090', fg='white') self.remove_book_label.pack() self.remove_book_entry = tk.Entry(self.master, font=("Helvetica", 12)) self.remove_book_entry.pack() self.remove_book_button = tk.Button(self.master, text="Remove Book", command=self.remove_book, font=("Helvetica", 12)) self.remove_book_button.pack() self.issue_book_label = tk.Label(self.master, text="Issue Book", font=("Helvetica", 16), bg='#708090', fg='white') self.issue_book_label.pack() self.issue_book_entry = tk.Entry(self.master, font=("Helvetica", 12)) self.issue_book_entry.pack() self.issue_book_button = tk.Button(self.master, text="Issue Book", command=self.issue_book, font=("Helvetica", 12)) self.issue_book_button.pack() self.view_books_button = tk.Button(self.master, text="View Books", command=self.view_books, font=("Helvetica", 12)) self.view_books_button.pack()

Library Management System Python GUI Introduction: This Library Management System project is a Python-based solution that utilizes the tkinter library to create a graphical user interface (GUI). Its main goal is to simplify and streamline the process of managing books and library members. The code includes a class named “Library Management,” which holds several methods and variables that handle the different features of the system, including login, registration, adding books, removing books, issuing books, and returning books. Although this implementation is basic, it offers room for future enhancements and upgrades. Explanation ‘import tkinter as tk’: This line imports the tkinter library and creates an alias tk to reference it easily. ‘from tkinter import messagebox’: This line imports the messagebox module from the tkinter library, which provides dialog boxes to display messages. 3. The class ‘LibraryManagement’ is defined, which has a constructor method ‘ init ‘. The ‘ init ‘ method creates a window with a title, dimensions, and a background color. It also initializes lists for books and a lend list. Labels and entry boxes for username and password are created, along with Login and Register buttons. The ‘login’ method checks the entered username and password against a list of librarians. If the credentials are correct, the login interface is destroyed and the ‘library_management_screen’ method is called. The register method adds the entered username and password to the list of librarians. The ‘library_management_screen’ method creates labels, entry boxes, and buttons for adding, removing, issuing, and viewing books. The ‘add_book’ method adds the entered book to the list of books and displays a success message. The ‘remove_book’ method removes the entered book from the list of books if it exists and displays a success message, or an error message if it doesn’t exist. The ‘issue_book’ method moves the entered book from the list of books to the lend list if it exists and displays a success message, or an error message if it doesn’t exist. The ‘view_books’ method displays a message box with a list of all the books in the library. The if name == “ main “: block creates a ‘Tk’ object, initializes an instance of ‘LibraryManagement’, and starts the main event loop to display the window.

Code Explanation: The code starts by importing the required libraries. Then, it declares the global variables for storing the ‘x’ or ‘o’ value as character. Next, it stores the winner’s value at any instant of code. To check if the game is a draw, there is a variable called draw that will be set to None when we are done with this function and then used in other functions later on in this program. The next step is to set up some variables for width of the game window and height of the game window which will be 400 pixels wide and 400 pixels tall respectively. It also sets background color of the game window to white (255, 255, 255). The color of straightlines on that white board dividing into 9 parts is line_color = (0, 0, 0) while setting up a 3 * 3 board in canvas creates an empty array where each element has three spaces followed by two more elements which create nine squares on our tic tac toe board. Lastly it initializes pygame window with pg.init() method before loading images as python object using pg image library methods such as load(“modified_cover.png”) , x_img = pg .image .load(“X_modified.”), y_img = pg The code is a snippet of code that displays the game board in canvas. The code declares global variables such as winner, draw, XO and line_color. The code sets up the game window with width and height values. The background color is white which is set to be 255, 255, 255. The code starts by checking for the winner of the game. If there is no winner, then it prints “XO’s Turn” and sets a font object to print text on screen. The code checks for winning rows and columns. It also checks if there are diagonal winners in order to determine who won diagonally left or right. The next part of the code starts with a function called check_win(). This function loops through all four possible combinations of winning rows and columns, which will be used later when determining who won diagonally left or right. After this loop finishes, it determines whether XO has won by checking if board[0][0] == board[1][1] == board[2][2]. If so, then XO wins because they have three in a row horizontally (left-to-right) and two vertically (top-to-bottom). The code is a basic game of tic-tac-toe. The player who gets three in a row first wins the game. The code begins by declaring variables for the board, winner, and draw. The variable board will be used to store information about the current state of the game such as which rows and columns are won or lost. The variable winner will store information about who has won the game so far. The variable draw will hold whether or not there is a winner yet. After declaring these variables, two functions are created: check_win() and draw_status(). These functions are called when it’s time to check if someone has won or when it’s time to update what is displayed on screen during gameplay The code starts by defining a function called drawXO. This function takes in two parameters: the row and the col of where to place an image on the screen. The first parameter is defined as being 30 from the left margin, so for each row, we need to define what position it should be pasted at. For example, if you wanted to paste an image over column 1, then you would set posx = width / 3 + 30. The next line defines that XO will always be ‘o’ when it’s not drawing anything else and ‘x’ when it is drawing something else. Then comes a function called user_click which gets coordinates of mouse clicks and draws images accordingly based on those coordinates. It also checks whether there is a winner or not before doing anything else with them (i.e., checking who won). Lastly, reset_game resets everything back to how they were originally before starting up again with game_initiating_window(). The code is a program that plays Tic-Tac-Toe. The code starts by defining the board, which is an array of three rows and three columns with the value None in each cell. The game_initiating_window() function is called to start the game. If you want to play again, you can call reset_game(). The

Code Explanation: The code starts by importing the required libraries. Then, it declares the global variables for storing the ‘x’ or ‘o’ value as character. Next, it stores the winner’s value at any instant of code. To check if the game is a draw, there is a variable called draw that will be set to None when we are done with this function and then used in other functions later on in this program. The next step is to set up some variables for width of the game window and height of the game window which will be 400 pixels wide and 400 pixels tall respectively. It also sets background color of the game window to white (255, 255, 255). The color of straightlines on that white board dividing into 9 parts is line_color = (0, 0, 0) while setting up a 3 * 3 board in canvas creates an empty array where each element has three spaces followed by two more elements which create nine squares on our tic tac toe board. Lastly it initializes pygame window with pg.init() method before loading images as python object using pg image library methods such as load(“modified_cover.png”) , x_img = pg .image .load(“X_modified.”), y_img = pg The code is a snippet of code that displays the game board in canvas. The code declares global variables such as winner, draw, XO and line_color. The code sets up the game window with width and height values. The background color is white which is set to be 255, 255, 255. The code starts by checking for the winner of the game. If there is no winner, then it prints “XO’s Turn” and sets a font object to print text on screen. The code checks for winning rows and columns. It also checks if there are diagonal winners in order to determine who won diagonally left or right. The next part of the code starts with a function called check_win(). This function loops through all four possible combinations of winning rows and columns, which will be used later when determining who won diagonally left or right. After this loop finishes, it determines whether XO has won by checking if board[0][0] == board[1][1] == board[2][2]. If so, then XO wins because they have three in a row horizontally (left-to-right) and two vertically (top-to-bottom). The code is a basic game of tic-tac-toe. The player who gets three in a row first wins the game. The code begins by declaring variables for the board, winner, and draw. The variable board will be used to store information about the current state of the game such as which rows and columns are won or lost. The variable winner will store information about who has won the game so far. The variable draw will hold whether or not there is a winner yet. After declaring these variables, two functions are created: check_win() and draw_status(). These functions are called when it’s time to check if someone has won or when it’s time to update what is displayed on screen during gameplay The code starts by defining a function called drawXO. This function takes in two parameters: the row and the col of where to place an image on the screen. The first parameter is defined as being 30 from the left margin, so for each row, we need to define what position it should be pasted at. For example, if you wanted to paste an image over column 1, then you would set posx = width / 3 + 30. The next line defines that XO will always be ‘o’ when it’s not drawing anything else and ‘x’ when it is drawing something else. Then comes a function called user_click which gets coordinates of mouse clicks and draws images accordingly based on those coordinates. It also checks whether there is a winner or not before doing anything else with them (i.e., checking who won). Lastly, reset_game resets everything back to how they were originally before starting up again with game_initiating_window(). The code is a program that plays Tic-Tac-Toe. The code starts by defining the board, which is an array of three rows and three columns with the value None in each cell. The game_initiating_window() function is called to start the game. If you want to play again, you can call reset_game(). The

Full Code :- # importing the required librariesimport pygame as pg import sysimport time from pygame.locals import * # declaring the global variables # for storing the 'x' or 'o'# value as character XO = 'x' # storing the winner's value at# any instant of code winner = None # to check if the game is a drawdraw = None # to set width of the game window width = 400 # to set height of the game windowheight = 400 # to set background color of the # game windowwhite = (255, 255, 255) # color of the straightlines on that # white game board, dividing board# into 9 parts line_color = (0, 0, 0) # setting up a 3 * 3 board in canvasboard = [[None]*3, [None]*3, [None]*3] # initializing the pygame windowpg.init() # setting fps manually fps = 30 # this is used to track timeCLOCK = pg.time.Clock() # this method is used to build the # infrastructure of the displayscreen = pg.display.set_mode((width, height + 100), 0, 32) # setting up a nametag for the # game windowpg.display.set_caption("My Tic Tac Toe") # loading the images as python object initiating_window = pg.image.load("modified_cover.png")x_img = pg.image.load("X_modified.png") y_img = pg.image.load("o_modified.png") # resizing imagesinitiating_window = pg.transform.scale( initiating_window, (width, height + 100))x_img = pg.transform.scale(x_img, (80, 80)) o_img = pg.transform.scale(y_img, (80, 80)) def game_initiating_window(): # displaying over the screen screen.blit(initiating_window, (0, 0)) # updating the display pg.display.update() time.sleep(3) screen.fill(white) # drawing vertical lines pg.draw.line(screen, line_color, (width / 3, 0), (width / 3, height), 7) pg.draw.line(screen, line_color, (width / 3 * 2, 0), (width / 3 * 2, height), 7) # drawing horizontal lines pg.draw.line(screen, line_color, (0, height / 3), (width, height / 3), 7) pg.draw.line(screen, line_color, (0, height / 3 * 2), (width, height / 3 * 2), 7) draw_status() def draw_status(): # getting the global variable draw # into action global draw if winner is None: message = XO.upper() + "'s Turn" else: message = winner.upper() + " won !" if draw: message = "Game Draw !" # setting a font object font = pg.font.Font(None, 30) # setting the font properties like # color and width of the text text = font.render(message, 1, (255, 255, 255)) # copy the rendered message onto the board # creating a small block at the bottom of the main display screen.fill((0, 0, 0), (0, 400, 500, 100)) text_rect = text.get_rect(center=(width / 2, 500-50)) screen.blit(text, text_rect) pg.display.update() def check_win(): global board, winner, draw # checking for winning rows for row in range(0, 3): if((board[row][0] == board[row][1] == board[row][2]) and (board[row][0] is not None)): winner = board[row][0] pg.draw.line(screen, (250, 0, 0), (0, (row + 1)*height / 3 - height / 6), (width, (row + 1)*height / 3 - height / 6), 4) break # checking for winning columns for col in range(0, 3): if((board[0][col] == board[1][col] == board[2][col]) and (board[0][col] is not None)): winner = board[0][col] pg.draw.line(screen, (250, 0, 0), ((col + 1) * width / 3 - width / 6, 0), ((col + 1) * width / 3 - width / 6, height), 4) break # check for diagonal winners if (board[0][0] == board[1][1] == board[2][2]) and (board[0][0] is not None): # game won diagonally left to right winner = board[0][0] pg.draw.line(screen, (250, 70, 70), (50, 50), (350, 350), 4) if (board[0][2] == board[1][1] == board[2][0]) and (board[0][2] is not None): # game won diagonally right to left winner = board[0][2] pg.draw.line(screen, (250, 70, 70), (350, 50), (50, 350), 4) if(all([all(row) for row in board]) and winner is None): draw = True draw_status() def drawXO(row, col): global board, XO # for the first row, the image # should be pasted at a x coordinate # of 30 from the left margin if row == 1: posx = 30 # for the second row, the image # should be pasted at a x coordinate # of 30 from the game line if row == 2: # margin or width / 3 + 30 from # the left margin of the

Tic Tac Toe GUI In Python using PyGame This Post will guide you and give you a basic idea of designing a game Tic Tac Toe using pygame library of Python. Pygame is a cross-platform set of Python modules designed for writing video games. It includes computer graphics and sound libraries designed to be used with the Python programming language. Let’s break the task in five parts: 1.Importing the required libraries and setting up the required global variables.2.Designing the game display function, that will set a platform for other components to be displayed on the screen. 3.Main algorithm of win and draw4.Getting the user input and displaying the “X” or “O” at the proper position where the user has clicked his mouse. 5.Running an infinite loop, and including the defined methods in it. Importing the required libraries and setting up the required global variables We are going to use the pygame, time, and the sys library of Python. time library is used to keep track of time and sleep() method that we are going to use inside our code. Have a look at the code below. Importing the required libraries and setting up the required global variablesWe are going to use the pygame, time, and the sys library of Python. time library is used to keep track of time and sleep() method that we are going to use inside our code. Have a look at the code below. # importing the required librariesimport pygame as pg import sysimport time from pygame.locals import * # declaring the global variables # for storing the 'x' or 'o'# value as character XO = 'x' # storing the winner's value at# any instant of code winner = None # to check if the game is a drawdraw = None # to set width of the game window width = 400 # to set height of the game windowheight = 400 # to set background color of the # game windowwhite = (255, 255, 255) # color of the straightlines on that # white game board, dividing board# into 9 parts line_color = (0, 0, 0) # setting up a 3 * 3 board in canvasboard = [[None]*3, [None]*3, [None]*3] Designing the game display This is the trickier part, that makes the utmost importance in game development. We can use the display.set_mode() method to set up our display window. This takes three arguments, first one being a tuple having (width, height) of the display that we want it to be, the other two arguments are depth and fps respectively.display.set_caption(), sets a caption on the name tag of our display. pg.image.load() is an useful method to load the background images to customize the display. This method takes the file name as an argument along with the extension. There is a small problem with image.load(), it loads the image as a Python object in its native size, which may not be optimized along with the display. So we use another method in pygame known as pg.transform.scale(). This method takes two arguments, one being the name of the image object and the other is a tuple having (width, height), that we want our image to scale to. Finally we head to the first function, game_initiating_window(). On the very first line there is a screen.blit() function. The screen is the Python function and blit is the method that enables pygame to display something over another thing. Here out image object has been displayed over the screen, which was set white initially. pg.display.update() is another important function in game development. It updates the display of our window when called. Pygame also enables us to draw geometric objects like line, circle, etc. In this project we have used pg.draw.line() method that takes five arguments, namely – (display, line color, starting point, ending point, width). This involves a little bit of coordinate geometry to draw the lines properly. This is not sufficient. At each update of the display we need to know the game status, Whether it is win or lose.draw_status() helps us in displaying another 100pc window at the bottom of the main window, that updates the status at each click of the user. # initializing the pygame window pg.init() # setting fps manuallyfps = 30 # this is used to track

Output

Python | ToDo GUI Application using Tkinter 🔥🚀 Python offers multiple options for developing GUI (Graphical User Interface). Out of all the GUI methods, Tkinter is the most commonly used method To create a tkinter : Importing the module – tkinterCreate the main window (container) Add any number of widgets to the main window.Apply the event Trigger on the widgets. Code :- # import all functions from the tkinter from tkinter import * # import messagebox class from tkinter from tkinter import messagebox # global list is declare for storing all the tasktasks_list = [] # global variable is declare for counting the task counter = 1 # Function for checking input error when# empty input is given in task field def inputError() : # check for enter task field is empty or not if enterTaskField.get() == "" : # show the error message messagebox.showerror("Input Error") return 0 return 1 # Function for clearing the contents # of task number text fielddef clear_taskNumberField() : # clear the content of task number text field taskNumberField.delete(0.0, END) # Function for clearing the contents# of task entry field def clear_taskField() : # clear the content of task field entry box enterTaskField.delete(0, END) # Function for inserting the contents # from the task entry field to the text area def insertTask(): global counter # check for error value = inputError() # if error occur then return if value == 0 : return # get the task string concatenating # with new line character content = enterTaskField.get() + "\n" # store task in the list tasks_list.append(content) # insert content of task entry field to the text area # add task one by one in below one by one TextArea.insert('end -1 chars', "[ " + str(counter) + " ] " + content) # incremented counter += 1 # function calling for deleting the content of task field clear_taskField() # function for deleting the specified task def delete() : global counter # handling the empty task error if len(tasks_list) == 0 : messagebox.showerror("No task") return # get the task number, which is required to delete number = taskNumberField.get(1.0, END) # checking for input error when # empty input in task number field if number == "\n" : messagebox.showerror("input error") return else : task_no = int(number) # function calling for deleting the # content of task number field clear_taskNumberField() # deleted specified task from the list tasks_list.pop(task_no - 1) # decremented counter -= 1 # whole content of text area widget is deleted TextArea.delete(1.0, END) # rewriting the task after deleting one task at a time for i in range(len(tasks_list)) : TextArea.insert('end -1 chars', "[ " + str(i + 1) + " ] " + tasks_list[i]) # Driver code if name == "main" : # create a GUI window gui = Tk() # set the background colour of GUI window gui.configure(background = "light green") # set the title of GUI window gui.title("ToDo App") # set the configuration of GUI window gui.geometry("250x300") # create a label : Enter Your Task enterTask = Label(gui, text = "Enter Your Task", bg = "light green") # create a text entry box # for typing the task enterTaskField = Entry(gui) # create a Submit Button and place into the root window # when user press the button, the command or # function affiliated to that button is executed Submit = Button(gui, text = "Submit", fg = "Black", bg = "Red", command = insertTask) # create a text area for the root # with lunida 13 font # text area is for writing the content TextArea = Text(gui, height = 5, width = 25, font = "lucida 13") # create a label : Delete Task Number taskNumber = Label(gui, text = "Delete Task Number", bg = "blue") taskNumberField = Text(gui, height = 1, width = 2, font = "lucida 13") # create a Delete Button and place into the root window # when user press the button, the command or # function affiliated to that button is executed . delete = Button(gui, text = "Delete", fg = "Black", bg = "Red", command = delete) # create a Exit Button and place into the root

Downloade file for flippy bird game code

Flappy Bird Game Using Pythpn 😍😍 Introduction: In this project, we have created a game using the “Pygame” module in python. The game is named “Flappy Bird”. Most of you have played this game on your mobile phones and now it’s time to code this game by yourself. If you haven’t played this before, not an issue, let’s cover this introduction with these few lines. The game is a side-scroller where the player controls a bird, attempting to fly between columns of green pipes without hitting them, and scores for the same. Explanation: The most basic need to work under the module is to import them. With the help of the “import” keyword, we will import all the libraries needed. Along with “pygame”, we will also import the “sys”, “time”, and “random” modules.Before talking about the process in which we have to code, let’s discuss the raw elements first and along with them the objectives as well: *Firstly, for making this game the raw elements which will be needed:A birdA background image A floor imagePipe imageGame over message image* After discussing the elements, let’s discuss the objectives under which these elements will be used: We need to create an animation that will treat the user’s eye as if the bird is moving ahead and by moving the base we will do so.To make the bird fly and rotate.Create the pipes at the top and bottom and show them in animation as well. For maintaining the rules, we have to code for setting the parameters for scoring a point and losing the game by hitting the pipes and surfacesThe basic steps are to initialize the pygame module by the “.init()” method and set the frames per second by the “pygame.time.Clock() “method of the “random” module.First of all, to create a game window we will use the “pygame.display.set_mode(width, height)” method and to set the caption of our window we will use “pygame.display.set_caption( )”. Now we will make a game loop using a “while” loop under this we will run a “for” loop for getting the events with the help of “pygame.event.get()” and to check the event type we will make use of “.type”. firstly, we will check for the quit event with the help of “pygame. QUIT”.In this project, we will make 5 user-defined functions named: draw_floor( )create_pipes( )pipe_animation( ) draw_score( )score_update( )Now starting with the game, the most basic need is to set a background image for our window screen. Firstly, we will load the image and then we will blit it on the screen, the blitting means to draw that particular image. To load the image we will use “pygame.image.load(‘image path or image name’)” and “screen. blit(‘source’,’ position’)” is being used to blit the particular image on the screen under the game loop. With the help of these two functions and the variable named “back_img” we will set the background image, and to update the game window with the changes we will use the “pygame.display.update()” function. After drawing the background image we will need a floor image and with the same process under the variable named “floor_img”, we will load and then blit the floor image on the game window.The next step is to move the floor and for doing so we will create a variable called “floor_x” and declare it initially as 0. Now under the game loop we will subtract the 1 from our variable and to move it continuously we will blit the floor image by adding 448 to our x position. All of this will be done under our first user-defined function “draw_floor( )” and the floor may not get disappeared so under the game loop we will check the condition of the floor_x will be less than -448 then again the floor_x will be set as 0. Due to this condition, we can see that the base on our game window will move continuously The next most important step is to draw a bird on the screen and for showing the movement of the bird we will use three images of a bird at different stages. That is a bird with an up flap, a bid with a mid flap, and a bird with a down flap. We will load these images and blit them with the help of the same functions. Now to show these different images we will

Python – Cows and Bulls game Cows and Bulls is a pen and paper code-breaking game usually played between 2 players. In this, a player tries to guess a secret code number chosen by the second player. The rules are as follows: A player will create a secret code, usually a 4-digit number. This number should have no repeated digits. Another player makes a guess (4 digit number) to crack the secret number. Upon making a guess, 2 hints will be provided- Cows and Bulls. Bulls indicate the number of correct digits in the correct position and cows indicates the number of correct digits in the wrong position. For example, if the secret code is 1234 and the guessed number is 1246 then we have 2 BULLS (for the exact matches of digits 1 and 2) and 1 COW (for the match of digit 4 in the wrong position) The player keeps on guessing until the secret code is cracked. The player who guesses in the minimum number of tries wins. To create this game in Python, the computer generates a secret code and the user will have to guess the code. Break it down into these blocks: Generate a secret code- Generate a random 4-digit number and check that it does not have any repeated digits. Generate hint or response- Take the generated 4-digit secret number and the guessed number (input). Find the common digits with exact matches (bulls) and the common digits in the wrong position (cows). Repeat with each guess until you have 4 bulls (an exact match) or you run out of tries. Constraint: The secret code and the guessed code should be of 4-digits (between 1000 and 9999) and have no repeated numbers. #code :-# Import required module import random # Returns list of digits # of a number def getDigits(num): return [int(i) for i in str(num)] # Returns True if number has # no duplicate digits # otherwise False def noDuplicates(num): num_li = getDigits(num) if len(num_li) == len(set(num_li)): return True else: return False # Generates a 4 digit number # with no repeated digits def generateNum(): while True: num = random.randint(1000,9999) if noDuplicates(num): return num # Returns common digits with exact # matches (bulls) and the common # digits in wrong position (cows) def numOfBullsCows(num,guess): bull_cow = [0,0] num_li = getDigits(num) guess_li = getDigits(guess) for i,j in zip(num_li,guess_li): # common digit present if j in num_li: # common digit exact match if j == i: bull_cow[0] += 1 # common digit match but in wrong position else: bull_cow[1] += 1 return bull_cow # Secret Code num = generateNum() tries =int(input('Enter number of tries: ')) # Play game until correct guess # or till no tries left while tries > 0: guess = int(input("Enter your guess: ")) if not noDuplicates(guess): print("Number should not have repeated digits. Try again.") continue if guess < 1000 or guess > 9999: print("Enter 4 digit number only. Try again.") continue bull_cow = numOfBullsCows(num,guess) print(f"{bull_cow[0]} bulls, {bull_cow[1]} cows") tries -=1 if bull_cow[0] == 4: print("You guessed right!") breakelse: print(f"You ran out of tries. Number was {num}")

Earn up to 69 LPA! 🔥 This dedicated course places you in SDE roles at Google, Amazon, and more! Hurry. Only 30 working profe
Earn up to 69 LPA! 🔥 This dedicated course places you in SDE roles at Google, Amazon, and more! Hurry. Only 30 working professionals will be selected! Signup now! https://bit.ly/45ogUx3