# data[].attributes.body
balance = 100
menu = 1
amount = 0

def select_menu():
    global menu
    print("กรุณาเลือกเมนู")
    menu = int(input("1: ฝาก / 2: ถอน / 3: ถามยอด / 0: ยกเลิก >>"))
    if menu ==0:
        print("จบโปรแกรม")
    elif menu in range (1, 3):
        get_amount()
    elif menu == 3:
        show_balance()


def get_amount():
    global amount
    a = int(input("จำนวนเงิน >>"))
    amount = a
    if menu == 1:
        deposit()
    elif menu ==2:
        withdraw()


def deposit():
    global balance
    balance = balance + amount
    show_balance()

def withdraw():
    global balance
    if amount <= balance:
        balance = balance - amount
        show_balance()
    else:
        print("ยอดเงินไม่เพียงพอ")

def show_balance():
    print("ยอดเงินคงเหลือ:  ", balance)
    select_menu()

# data[].attributes.body
from tkinter import*

frame = Tk()

frame.geometry("500x300")

frame.title("HAHAHAHA")

L1 = Label(frame,text="Hello", font=('Arial', 25), bg ="black", fg="white")

L1.place(x=100,y=200)

frame.mainloop()

# data[].attributes.body
from tkinter import*

from datetime import datetime

import time

def update_clock():

now = datetime.now()

current_date = now.strftime("%d / %m / %Y")

current_time = now.strftime("%H:%M:%S")

L1.config(text = current_date)

L2.config(text = current_time)

frame.after(1000,update_clock)

frame = Tk()

frame.title("GUI - 1")

frame.geometry("300x200")

L1 = Label(frame,text = "Date", font = ("Tahoma",20))

L1.pack()

L2 = Label(frame,text = "Time", font = ("Tahoma",20))

L2.pack()

update_clock()

frame.mainloop()

# data[].attributes.body
from tkinter import*

from datetime import datetime

import time

def update_clock():

global cl

now = datetime.now()

current_date = now.strftime("%d / %m / %Y")

current_time = now.strftime("%H:%M:%S")

L1.config(text = current_date)

L2.config(text = current_time)

cl = frame.after(1000,update_clock)

def stop_click():

global cl

frame.after_cancel(cl)

frame = Tk()

frame.title("GUI - 1")

frame.geometry("300x200")

cl = None

L1 = Label(frame,text = "Date", font = ("Tahoma",20))

L1.pack()

L2 = Label(frame,text = "Time", font = ("Tahoma",20))

L2.pack()

B1 = Button(frame, text = "Start" ,command = update_clock)

B1.pack()

B2 = Button(frame, text = "Stop", command = stop_click)

B2.pack()

frame.mainloop()

# data[].attributes.body
from openpyxl import*

wb = load_workbook("record.xlsx")

wb.active = wb["Sheet1"]

sheet = wb.active

print("Fully Access to Excel Sheet")

from tkinter import*

frame = Tk()

frame.geometry('300x200')

from datetime import datetime

def on_click():

value_s1 = var.get()

now = datetime.now()

last_row = sheet.max_row+1

point_to_cell_time = sheet.cell(last_row,column=1)

point_to_cell_value = sheet.cell(last_row,column=2)

point_to_cell_time.value = now

point_to_cell_value.value = value_s1

wb.save("record.xlsx")

print("Value was record")

var = DoubleVar()

S1 = Scale(frame, resolution=0.001, variable = var, orient = "horizontal", label="SCALE", from_ = -100, to = 100, length=200, width = 30)

S1.pack()

B1 = Button(frame, text= "OK", command = on_click)

B1.pack()

frame.mainloop()

# data[].attributes.attachment_link.title
ภาพถ่ายที่เลือก

# data[].attributes.attachment_link.title
ภาพถ่ายที่เลือก (3)

# data[].attributes.body
import tkinter as tk

from tkinter import messagebox

import csv

# Function to save data to CSV file

def save_to_csv(data):

file_exists = False

try:

with open('names.csv', 'r') as file:

file_exists = True

except FileNotFoundError:

pass

with open('names.csv', 'a', newline='') as file:

fieldnames = ['First Name', 'Last Name']

writer = csv.DictWriter(file, fieldnames=fieldnames)

if not file_exists:

writer.writeheader()

writer.writerow(data)

# Function to handle the submit button click

def submit():

first_name = entry_first_name.get()

last_name = entry_last_name.get()

if first_name and last_name:

data = {'First Name': first_name, 'Last Name': last_name}

#save_to_csv(data)

messagebox.showinfo("Success", "Data saved successfully!")

entry_first_name.delete(0, tk.END)

entry_last_name.delete(0, tk.END)

else:

messagebox.showwarning("Input Error", "Please enter both first name and last name")

# Create the main window

root = tk.Tk()

root.title("Name Collector")

# Create and place the widgets

label_first_name = tk.Label(root, text="First Name:")

label_first_name.grid(row=0, column=0, padx=10, pady=5)

entry_first_name = tk.Entry(root)

entry_first_name.grid(row=0, column=1, padx=10, pady=5)

label_last_name = tk.Label(root, text="Last Name:")

label_last_name.grid(row=1, column=0, padx=10, pady=5)

entry_last_name = tk.Entry(root)

entry_last_name.grid(row=1, column=1, padx=10, pady=5)

submit_button = tk.Button(root, text="Submit", command=submit)

submit_button.grid(row=2, columnspan=2, pady=10)

# Run the main event loop

root.mainloop()

# data[].attributes.body
// https://www.w3schools.com/python/pandas/data.js

# data[].attributes.body
// https://www.w3schools.com/python/pandas/data.csv

# data[].attributes.body
//https://drive.google.com/file/u/0/d/17XszLX8k8O0hYx9kfYH07NDzKJKsk9WS/view?usp=sharing&pli=1

# data[].attributes.body
please act as python data scientist.

i have csv file named "train.csv" that run in google colab.

now i have dataframe with pandas by code

import pandas as pd

df = pd.read_csv("train.csv")

in the df have filed name "Sex" that contain 891 record.

i want you create python with mathplotlib to show bar graph that compare number of male and female from df[sex].

# data[].attributes.body
Write a Python program to simulate and analyze sales data for a retail store. The program should:

Generate a dataset of sales data for 12 months using NumPy.

Load the generated dataset into a Pandas DataFrame.

Calculate and display basic statistics (mean, median, total) for sales amounts.

Plot a bar chart of total sales per month using Matplotlib.

Plot a line chart of cumulative sales over time using Matplotlib.

# data[].attributes.body
please act as python analyze expert.

i have dataset like this,

age sex bmi children smoker region charges 19 female 27.9 0 yes southwest 16884.924 18 male 33.77 1 no southeast 1725.5523 28 male 33 3 no southeast 4449.462 33 male 22.705 0 no northwest 21984.47061 32 male 28.88 0 no northwest 3866.8552 31 female 25.74 0 no southeast 3756.6216

please create python code by using numpy pandas matplotlib sklearn_multiple_linear regression

we will run code on google colab. first, import file name insurance.csv to dataframe. next, split data for train and test. next, fit the multiple linear regression model to predict "charge" next, eveluate the model with mse, and r2 next, plot graph about variable that used in model. and also show relation between variables.

# data[].attributes.body
please act as python expert. now, i make the multiple linear regression model by using this code:

X = df[['age', 'bmi', 'children']] # Independent variables y = df['charges'] # Dependent variable (target)

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=0)

model = LinearRegression() model.fit(X_train, y_train)

after this, please write the python code to create function for model implement. this funtion will: prompt user input number of "age" prompt user input number of "bmi" prompt user input number of "children" then use 3 value from input with model and print the "charges" predict value.

# data[].attributes.body
https://drive.google.com/file/d/10XorvCxDr-UL2hoKWf8PvXoeww1ue28j/view?usp=drive_link

# data[].attributes.body
please act as python data scientist. Dataset Description You have been provided with a dataset containing the following columns: Hours Studied: The number of hours a student studied for the exam. Passed: A binary indicator (0 or 1) representing whether the student passed the exam or not. A value of 1 indicates the student passed, while a value of 0 indicates failure. The dataset contains 100 samples with these two features. example in file named "hour_studied_data": HoursStudied Passed 5.488135039 0 7.151893664 1 6.027633761 1 5.44883183 0 please write the code using numpy pandas matplotlib. create model logistic regression by sklearn evaluate model with r2 and other importance value. plot graph to show curve of logistic regression from model. write the function to use the model with pywidget in google colab.

# data[].attributes.body
please act as Python data sci. You working for a retail company that wants to optimize its marketing strategy by understanding its customers better. The company has collected data on customer purchases and wants to segment customers into distinct groups to target each group with tailored marketing campaigns. Dataset Description You have been provided with a dataset containing the following columns: TotalAmountSpent: The total amount of money spent by the customer. NumberOfTransactions: The total number of transactions made by the customer. AvgTransactionValue: The average value of each transaction. The dataset in file named "retail_customer_data.csv" contains 100 samples with these three features. in example: TotalAmountSpent NumberOfTransactions AvgTransactionValue 599.3428306 6 99.89047177 472.3471398 11 42.94064907 629.5377076 8 78.69221345 804.6059713 10 80.46059713 453.1693251 9 50.35214723 please create the python code to make the K mean clustering model. may use numpy pandas matplotlib pywidget seabon sklearn pysci code step1: import file into google colab code setp2: make datafram code step3: prepare data and make K mean model. code step4: adjust the k number for very well model. code step5: evaluate model code step6: plot graph to show output of K mean clustering code step7: create function to get input from user to predict the cluster. input use pywidget GUI in colab.

# data[].attributes.body
%%writefile app.py
import streamlit as st
import joblib
import numpy as np

# Load the model from the .pkl file
model_file_path = 'salary_model.pkl'
model = joblib.load(model_file_path)

def main():
    st.title("Salary Predictor")
    st.write("Enter your years of experience to get a salary prediction.")

    # Get user input
    years_of_experience = st.number_input("Enter Year of Experience", min_value=0.0, step=0.1)

    # Predict salary based on user input
    if st.button("Predict Salary"):
        try:
            year_input = np.array([[years_of_experience]])
            salary_predict = model.predict(year_input)
            predicted_salary = salary_predict[0][0]  # Ensure we extract the scalar value
            st.write(f"Predicted Salary: ${predicted_salary:.2f}")
        except Exception as e:
            st.write("An error occurred during prediction.")
            st.write(e)
main()

# data[].attributes.body
!wget -q -O - ipv4.icanhazip.com

# data[].attributes.body
! streamlit run app.py & npx localtunnel --port 8501

# data[].attributes.body
!pip install streamlit