8.5 C
New York
Thursday, November 21, 2024
Blog Page 4

O Level Lessons Chapter 13 How to Solve the Task 13 i of Hodder 3rd Edition Book.

O Level Lessons Chapter 13 How to Solve the Task 13 H of Hodder 3rd Edition Book.

O Level Lessons Chapter 13 How to Solve the Task 13 G of Hodder 3rd Edition Book.

 

Download the Source Files and PDF Book From Here 

Download Now

O Level Lessons Chapter 13 How to Solve the Task 13 F of Hodder 3rd Edition Book.

 

Download the Source Files and PDF Book From Here 

Download Now

O Level Lessons Chapter 13 How to Solve the Task 13 C to Task 13 E of Hodder 3rd Edition Book.

Download the Source Files and PDF Book From Here 

Download Now

O Level Lessons Chapter 13 How to Solve the Task 13 A , Task 13 B of Hodder 3rd Edition Book.

 

Download the Source Files and PDF Book From Here 

Download Now

How to Code Calculator with Python, Tkinter, using ChatGPT

🧮 Ready to dive into the world of advanced calculators? In this comprehensive tutorial, we’ll guide you through the process of creating an intelligent scientific calculator using the power of Python, Tkinter for the user interface, and ChatGPT for natural language interaction. 🔍 We’ll cover a wide range of topics, including: Designing an intuitive user interface with Tkinter. Implementing advanced arithmetic and scientific functions. Enhancing user experience with natural language input using ChatGPT. Building a feature-rich calculator that simplifies complex calculations. 💡 Whether you’re a student, engineer, or math enthusiast, this tutorial will empower you to create your own powerful scientific calculator tailored to your needs. #Python #Tkinter #ChatGPT #ScientificCalculator #Tutorial #technotribe #technology #imranhussainkhan

 

Source Code Here

 

import tkinter as tk
import math
def button_click(number):
    current = entry.get()
    entry.delete(0, tk.END)
    entry.insert(tk.END, current + str(number))
def button_clear():
    entry.delete(0, tk.END)
def button_equal():
    expression = entry.get()
    try:
        result = eval(expression)
        entry.delete(0, tk.END)
        entry.insert(tk.END, result)
    except Exception as e:
        entry.delete(0, tk.END)
        entry.insert(tk.END, “Error”)
def button_sin():
    value = float(entry.get())
    result = math.sin(math.radians(value))
    entry.delete(0, tk.END)
    entry.insert(tk.END, result)
def button_cos():
    value = float(entry.get())
    result = math.cos(math.radians(value))
    entry.delete(0, tk.END)
    entry.insert(tk.END, result)
def button_tan():
    value = float(entry.get())
    result = math.tan(math.radians(value))
    entry.delete(0, tk.END)
    entry.insert(tk.END, result)
def button_log():
    value = float(entry.get())
    result = math.log10(value)
    entry.delete(0, tk.END)
    entry.insert(tk.END, result)
def button_factorial():
    value = int(entry.get())
    result = math.factorial(value)
    entry.delete(0, tk.END)
    entry.insert(tk.END, result)
root = tk.Tk()
root.title(“Calculator”)
entry = tk.Entry(root, width=30, font=(“Arial”, 18))
entry.grid(row=0, column=0, columnspan=5, padx=10, pady=10)
buttons = [
    ‘7’, ‘8’, ‘9’, ‘/’,
    ‘4’, ‘5’, ‘6’, ‘*’,
    ‘1’, ‘2’, ‘3’, ‘-‘,
    ‘0’, ‘.’, ‘=’, ‘+’,
    ‘C’, ‘sin’, ‘cos’, ‘tan’,
    ‘log’, ‘!’, ‘(‘, ‘)’
]
row = 1
col = 0
for button in buttons:
    if button == ‘=’:
        tk.Button(root, text=button, width=6, height=2, command=button_equal).grid(row=row, column=col)
    elif button == ‘C’:
        tk.Button(root, text=button, width=6, height=2, command=button_clear).grid(row=row, column=col)
    elif button == ‘sin’:
        tk.Button(root, text=button, width=6, height=2, command=button_sin).grid(row=row, column=col)
    elif button == ‘cos’:
        tk.Button(root, text=button, width=6, height=2, command=button_cos).grid(row=row, column=col)
    elif button == ‘tan’:
        tk.Button(root, text=button, width=6, height=2, command=button_tan).grid(row=row, column=col)
    elif button == ‘log’:
        tk.Button(root, text=button, width=6, height=2, command=button_log).grid(row=row, column=col)
    elif button == ‘!’:
        tk.Button(root, text=button, width=6, height=2, command=button_factorial).grid(row=row, column=col)
    else:
        tk.Button(root, text=button, width=6, height=2, command=lambda key=button: button_click(key)).grid(row=row, column=col)
    col += 1
    if col > 4:
        col = 0
        row += 1
root.mainloop()

 

Code NotePad in Python using ChatGPT

 

📝 In this tutorial, we’ll embark on a journey to develop a unique and intelligent notepad using Python and the incredible capabilities of ChatGPT. Say goodbye to ordinary text editors and welcome your own AI-powered writing assistant. 🌟 What to Expect: Build a feature-rich text editor with Python. Harness the power of ChatGPT to assist you in writing and generating content. Customize and enhance your notepad to make writing more efficient and enjoyable. Don’t forget to like, share, and subscribe for more exciting coding tutorials! #Python #ChatGPT #TextEditor #AIWritingAssistant #CodingTutorial #technotribe #technology #imranhussainkhan

 

 Source Code Here

import tkinter as tk
from tkinter import filedialog
from tkinter import messagebox
from tkinter import font as tkfont
def open_file():
    file_path = filedialog.askopenfilename()
    if file_path:
        with open(file_path, ‘r’) as file:
            text.delete(‘1.0’, tk.END)
            text.insert(tk.END, file.read())
def save_file():
    file_path = filedialog.asksaveasfilename(defaultextension=”.txt”)
    if file_path:
        with open(file_path, ‘w’) as file:
            file.write(text.get(‘1.0’, tk.END))
def save_file_as():
    file_path = filedialog.asksaveasfilename(defaultextension=”.txt”)
    if file_path:
        with open(file_path, ‘w’) as file:
            file.write(text.get(‘1.0’, tk.END))
def copy_text():
    text.clipboard_clear()
    text.clipboard_append(text.selection_get())
def cut_text():
    copy_text()
    text.delete(‘sel.first’, ‘sel.last’)
def paste_text():
    text.insert(‘insert’, text.clipboard_get())
def undo():
    try:
        text.edit_undo()
    except Exception:
        pass
def redo():
    try:
        text.edit_redo()
    except Exception:
        pass
def change_font():
    selected_font = font_var.get()
    text.config(font=(selected_font, font_size_var.get()))
def change_color():
    selected_color = color_var.get()
    text.config(fg=selected_color)
def print_text():
    try:
        text.printout()
    except Exception as e:
        messagebox.showerror(“Error”, f”Printing failed: {str(e)}”)
# Create the main window
root = tk.Tk()
root.title(“Notepad”)
# Create a Text widget for editing
text = tk.Text(root)
text.pack()
# Create a menu bar
menu_bar = tk.Menu(root)
root.config(menu=menu_bar)
# Create a File menu
file_menu = tk.Menu(menu_bar, tearoff=0)
menu_bar.add_cascade(label=”File”, menu=file_menu)
file_menu.add_command(label=”Open”, command=open_file)
file_menu.add_command(label=”Save”, command=save_file)
file_menu.add_command(label=”Save As”, command=save_file_as)
file_menu.add_separator()
file_menu.add_command(label=”Print”, command=print_text)
file_menu.add_separator()
file_menu.add_command(label=”Exit”, command=root.quit)
# Create an Edit menu
edit_menu = tk.Menu(menu_bar, tearoff=0)
menu_bar.add_cascade(label=”Edit”, menu=edit_menu)
edit_menu.add_command(label=”Undo”, command=undo)
edit_menu.add_command(label=”Redo”, command=redo)
edit_menu.add_separator()
edit_menu.add_command(label=”Copy”, command=copy_text)
edit_menu.add_command(label=”Cut”, command=cut_text)
edit_menu.add_command(label=”Paste”, command=paste_text)
# Create a View menu
view_menu = tk.Menu(menu_bar, tearoff=0)
menu_bar.add_cascade(label=”View”, menu=view_menu)
font_var = tkfont.Font(family=”Arial”, size=12)
font_size_var = tk.StringVar()
font_size_var.set(font_var.actual()[“size”])
font_menu = tk.Menu(view_menu, tearoff=0)
view_menu.add_cascade(label=”Font”, menu=font_menu)
font_menu.add_radiobutton(label=”Arial”, variable=font_var, value=”Arial”, command=change_font)
font_menu.add_radiobutton(label=”Times New Roman”, variable=font_var, value=”Times New Roman”, command=change_font)
font_menu.add_radiobutton(label=”Courier New”, variable=font_var, value=”Courier New”, command=change_font)
font_menu.add_radiobutton(label=”Verdana”, variable=font_var, value=”Verdana”, command=change_font)
font_size_menu = tk.Menu(view_menu, tearoff=0)
view_menu.add_cascade(label=”Font Size”, menu=font_size_menu)
font_size_menu.add_radiobutton(label=”10″, variable=font_size_var, value=”10″, command=change_font)
font_size_menu.add_radiobutton(label=”12″, variable=font_size_var, value=”12″, command=change_font)
font_size_menu.add_radiobutton(label=”14″, variable=font_size_var, value=”14″, command=change_font)
font_size_menu.add_radiobutton(label=”16″, variable=font_size_var, value=”16″, command=change_font)
color_var = tk.StringVar()
color_var.set(“black”)
color_menu = tk.Menu(view_menu, tearoff=0)
view_menu.add_cascade(label=”Text Color”, menu=color_menu)
color_menu.add_radiobutton(label=”Black”, variable=color_var, value=”black”, command=change_color)
color_menu.add_radiobutton(label=”Red”, variable=color_var, value=”red”, command=change_color)
color_menu.add_radiobutton(label=”Blue”, variable=color_var, value=”blue”, command=change_color)
# Start the main event loop
root.mainloop()

Build Tic Tac Toe Game using Python Code with the Help of ChatGPT

In this tutorial, I’ll try to provide you with how to get help from ChatGPT and code the Game. Try this source Code.

import tkinter as tk
from tkinter import messagebox
def check_winner():
    for combo in winning_combinations:
        a, b, c = combo
        if board[a] == board[b] == board[c] != “”:
            return board[a]
    return None
def check_draw():
    return “” not in board
def handle_click(index):
    global current_player
    global winner
    if board[index] == “” and not winner:
        board[index] = current_player
        buttons[index].config(text=current_player, state=tk.DISABLED)
        current_player = “X” if current_player == “O” else “O”
        winner = check_winner()
        if winner:
            messagebox.showinfo(“Tic Tac Toe”, f”Player {winner} wins!”)
            reset_game()
        elif check_draw():
            messagebox.showinfo(“Tic Tac Toe”, “It’s a draw!”)
            reset_game()
def reset_game():
    global board, current_player, winner
    board = [“”] * 9
    current_player = “X”
    winner = None
    for button in buttons:
        button.config(text=””, state=tk.NORMAL)
def exit_game():
    root.destroy()
winning_combinations = [(0, 1, 2), (3, 4, 5), (6, 7, 8),
                        (0, 3, 6), (1, 4, 7), (2, 5, 8),
                        (0, 4, 8), (2, 4, 6)]
root = tk.Tk()
root.title(“Tic Tac Toe”)
# Dark mode colors
bg_color = “#333”
text_color = “white”
font_size = 16
root.configure(bg=bg_color)
board = [“”] * 9
current_player = “X”
winner = None
buttons = [tk.Button(root, text=””, width=10, height=3, command=lambda i=i: handle_click(i), bg=bg_color, fg=text_color, font=(“Arial”, font_size)) for i in range(9)]
for i, button in enumerate(buttons):
    row = i // 3
    col = i % 3
    button.grid(row=row, column=col)
reset_button = tk.Button(root, text=”Reset”, command=reset_game, bg=bg_color, fg=text_color, font=(“Arial”, font_size))
reset_button.grid(row=3, column=0, columnspan=2)
exit_button = tk.Button(root, text=”Exit”, command=exit_game, bg=bg_color, fg=text_color, font=(“Arial”, font_size))
exit_button.grid(row=3, column=2, columnspan=2)
root.mainloop()

 

 

YouTube Downloader code in Python, Tkinter using ChatGPT

In this tutorial, I’ll create a YouTube Downloader using ChatGPT watch the video and try this Code.

Source Code is here:

import tkinter as tk
from tkinter import messagebox, ttk
from pytube import YouTube
import threading
import os
def download_video():
    video_url = url_entry.get()
    try:
        yt = YouTube(video_url)
        stream = yt.streams.get_highest_resolution()
        video_title = yt.title
        file_size = stream.filesize
        def download():
            stream.download(output_path=”C:/videos/”)
            messagebox.showinfo(“Success”, f”Video ‘{video_title}’ downloaded successfully!”)
        def update_progress():
            while stream.filesize > os.path.getsize(“C:/videos/” + stream.title + “.mp4”):
                bytes_downloaded = os.path.getsize(“C:/videos/” + stream.title + “.mp4”)
                percent = (bytes_downloaded / file_size) * 100
                progress_bar[‘value’] = percent  # Set the progress bar value directly
                root.update_idletasks()
            progress_bar[‘value’] = 100
            download()
        download_thread = threading.Thread(target=download)
        download_thread.start()
        progress_thread = threading.Thread(target=update_progress)
        progress_thread.start()
    except Exception as e:
        messagebox.showerror(“Error”, f”An error occurred: {str(e)}”)
# Create the main window
root = tk.Tk()
root.title(“YouTube Video Downloader”)
# Set the initial window size
root.geometry(“400×250”)  # Width x Height
# Create a custom style for the labels
label_style = ttk.Style()
label_style.configure(“CustomLabel.TLabel”, foreground=”#333″, font=(“Helvetica”, 12))
url_label = ttk.Label(root, text=”Enter YouTube URL:”, style=”CustomLabel.TLabel”)
url_label.pack(pady=10)
# Create a custom style for the entry widget
entry_style = ttk.Style()
entry_style.configure(“CustomEntry.TEntry”, font=(“Helvetica”, 12))
url_entry = ttk.Entry(root, width=40, style=”CustomEntry.TEntry”)
url_entry.pack(pady=10)
# Create a custom style for the buttons
button_style = ttk.Style()
button_style.configure(“CustomButton.TButton”, foreground=”black”, background=”#0074D9″, font=(“Helvetica”, 13))
download_button = ttk.Button(root, text=”Download”, command=download_video, style=”CustomButton.TButton”)
download_button.pack(pady=10)
# Create the progress bar
progress_bar = ttk.Progressbar(root, length=200, mode=’determinate’)
progress_bar.pack(pady=10)
root.mainloop()