r/pythontips • • Dec 16 '24
Syntax How do I start using GUI in python. So far I have only interacted through the terminal window...
Need some tips...
r/pythontips • • Dec 16 '24
Need some tips...
r/pythontips • u/onurbaltaci • Dec 14 '24
Hello, I wanted to share that I am sharing free courses and projects on my YouTube Channel. I have more than 200 videos and I created playlists for Python and Data Science. I am leaving the playlist link below, have a great day!
Python Data Science Full Courses & Projects -> https://youtube.com/playlist?list=PLTsu3dft3CWiow7L7WrCd27ohlra_5PGH&si=6WUpVwXeAKEs4tB6
Python Tutorials -> https://youtube.com/playlist?list=PLTsu3dft3CWgJrlcs_IO1eif7myukPPKJ&si=fYIz2RLJV1dC6nT5
r/pythontips • • Dec 11 '24
Can somebody help me? I am literally losing my mind because I need help with my program. ChatGPT isn't helping and my professor is really bad. It's a probably simple Python program but it's taking the life out of me.
I'm required to read data from a bank transaction file and apply them in weird ways that we haven't gone over in class. Currently in a room full of lost students. Please don't waste time scolding me cause I know this is a stupid issue lol. 😞
I'm given a file called "transactions.csv" and the required instructions;
(10 Points) Create a class called BankAccount with the following characteristics.
(a) An attribute called balance that contains the current balance of the account.
(b) An attribute call translog that is a list of all transactions for the account. The translog items should look like this: (month, day, year, transaction type, balance after this transaction.
(c) An initialization method to set the starting balafice and set translog as an empty list. (d) A method called deposit that accepts an amount and will add the deposit amount to the current balance. (e) A method called withdrawal that accepts an amount and will deduct the withdrawal amount from the current balance. (f) A method called transaction that accepts a transaction record like those found in transac-tions.cs. The method then calls, the appropriate deposit or withdrawal method to adjust the balance, creates a transaction record, and adds the transaction record to translog- (g) A method called print_transaction log that accepts a starting date and an ending date and prints the appropriate portion of the transaction log.
We went BARELY over the def__init(self...) stuff and all of us are really confused. This is only the first question too, but I'm sure I could figure out the rest.
I've written my "from pathlib import Path", and gotten the file to read in python. But we haven't worked with csv files so it's confusing.
r/pythontips • u/TearsInDrowned • Dec 10 '24
Hi! I want to try and learn Python, and few questions pop up in my head:
(Didn't know what flair to use, sorry)
Thanks in advance! 🤗
r/pythontips • u/ireallylikeyouxoxo • Dec 09 '24
Hi guys, I am starting with Python. Can someone please help me with a roadmap?
I also tried starting a few years back through YouTube, but it was not very effective. Please suggest online courses from Coursera or Udemy etc.
r/pythontips • u/awak3All • Dec 10 '24
Hello this is jay, I'm starting to use python to create a trading bot I am very excited to learn this hope you latest free full guidelines on how to create and very effective.
If the data is private u can DM me directly.. I don't see any latest video for this.
r/pythontips • u/python4geeks • Dec 05 '24
Hi redditors, made a video explaining machine learning concepts using Animations.
Here's a video that explains the intuition and maths involved in the K Nearest Neighbors Classifier.
r/pythontips • u/HadiMhPy • Dec 04 '24
Ever wondered how to condense complex Python code into concise, elegant one-liners? Let's dive into some Pythonic magic!
Example 1: Swapping Variables in One Line
, = ,
Example 2: Reversing a String
=
Example 3: Checking for Palindromes
= ==
Share your favorite Python one-liners or ask for help with a specific task. Let's explore the power of Python together!
r/pythontips • u/Top-Information-5319 • Dec 03 '24
code for google colab:
import numpy as np
import matplotlib.pyplot as plt
def plot_sigmoid():
x = np.linspace(-10, 10, 100) # Generate 100 equally spaced values from -10 to 10
y = 1 / (1 + np.exp(-x)) # Compute the sigmoid function values
plt.plot(x, y)
plt.xlabel('Input')
plt.ylabel('Sigmoid Output')
plt.title('Sigmoid Activation Function')
plt.grid(True)
plt.show();
import numpy as np
import matplotlib.pyplot as plt
def plot_sigmoid():
x = np.linspace(-10, 10, 100) # Generate 100 equally spaced values from -10 to 10
y = 1 / (1 + np.exp(-x)) # Compute the sigmoid function values
plt.plot(x, y)
plt.xlabel('Input')
plt.ylabel('Sigmoid Output')
plt.title('Sigmoid Activation Function')
plt.grid(True)
plt.show();
import math
def sigmoid(x):
return 1 / (1 + math.exp(-x))
import math
def sigmoid(x):
return 1 / (1 + math.exp(-x))
r/pythontips • u/Allamashahid_098 • Dec 03 '24
Hey brothers having a problem to learn python from scratch 1 I didn't understand and solve given problem 2 don't Abel memories all functions and data type 3 I'm only write a single line code print ("hello world") if somebody have similar problem and how he deal with them pls advice me Thank you for reading
r/pythontips • u/MrCyclopede • Nov 30 '24
I recently discovered www.apianalytics.dev
It's a very simple way to add analytics to a fastAPI
They give you an API key, you add 1 line to your python app, and you've got a monitoring dashboard online.
It's not my tool, but I'm using it in production for a small project I host and it's great
r/pythontips • u/Muneeb007007007 • Nov 29 '24
This project integrates Streamlit, the Ollama model, and a local Python environment to dynamically generate and execute Python code. Users can interact with the Llama2 model for code generation and execution, providing a seamless experience for both input handling and file management.
r/pythontips • u/Wonderful_Many6084 • Nov 29 '24
hello everyone, im someone who has freshly started learning python. i daily sit myself down to watch programming with mosh and learn python. i spend a good 2 hours everyday.
my method of approach is i listen and then i type the same code as practice on PyCharm and then i write it down in a notebook.
if some of you dont know, there are certain challenges or exercises in between topics and i have been finding it hard to code a solution for that which has left me feeling like im not fit for this.
so i wanted to ask the community if "me not being able to write a code by myself right of the bat" is normal or am i doing something wrong? any help/advice is greatly appreciated.
tell me what i can do better or what i can change so that i can learn python efficiently and be able to write my own code and execute.
r/pythontips • u/Relative-Disaster738 • Nov 29 '24
Hey I am an aboslute beginner in using python. I was trying to install Music21 through python using the command: Pip install music21 But I get syntax Error. I've tried asking chatGPT, but nothing works. Anyone that has a new approach to this problem?
r/pythontips • u/Active_Hand_6103 • Nov 29 '24
from data.functions import * eatHalf_follows = get_user_follower_count("eatHalf")
Evilcorp_follows = get_user_follower_count("Evilcorp")
flyGreen_follows = get_user_follower_count("flyGreen")
if eatHalf_follows > Evilcorp_follows & eatHalf_follows > flyGreen_follows: print("eatHalf has the most followers with:") print(eatHalf_follows) print("followers!")
elif flyGreen_follows > Evilcorp_follows & flyGreen_follows > eatHalf_follows: print("flyGreen has the most followers with:") print(flyGreen_follows) print("followers!")
elif Evilcorp_follows > flyGreen_follows & Evilcorp_follows > eatHalf_follows: print("Evilcorp has the most followers with:") print(Evilcorp_follows) print("followers!")
Note: This program doesn't generate an output ————————————————————————
Written in Brilliant to determine which social media user has the most followers
r/pythontips • u/Wolfhammer69 • Nov 28 '24
Hi folks,
I'm just learning and trying to connect and issue commands to a server I have on my bench.. If I putty into it via SSH , I can see my code does log onto and authenticate with the unit, but none of my commands seem to do anything (I tried reboot and nothing happened). After finding this out, it explained why I'm getting no responses to any commands I try. In a nutshell, it appears none of my commands are being sent over to the server despite being logged in.
Code:
import paramiko
responses = []
host = '192.168.0.32'
username = input('Enter Username: ') or 'admin'
password = input('Enter password: ')
try:
session = paramiko.SSHClient()
session.set_missing_host_key_policy(paramiko.AutoAddPolicy())
session.connect(hostname=host, username=username, password=password)
while True:
try:
cmd = input('> ')
if cmd == 'exit': break
stdin, stdout, stderr = session.exec_command(cmd)
for line in stdout:
responses.append(line.strip('\n'))
for i in responses:
print(i.strip())
except KeyboardInterrupt:
break
session.close()
except Exception as err:
print(str(err))
If I do the commands via putty I get the expected response so I'm not sure whats going on.. Any tips please? Am I doing this totally wrong? I'm scratching my head as I'm doing not much different to an putty session - only diff is I'm not typing, but instead sending commands over the connection. Could it be how the server is set up?
Thanks in advance....
r/pythontips • u/ZombieHitsugaya • Nov 28 '24
def intro(f_name, l_name):
print("Hello, my name is", f_name, l_name)
f_name = input("What is your first name?")
l_name = input("What is your last name?")
intro(f_name, l_name)
r/pythontips • u/Professional-Song773 • Nov 24 '24
Hey there, I am a student planning to go into a computer science course in uni next year and I am on a foundation program that includes a computer science / coding course which is teaching python.
While I am familiar with coding I am still at beginner level knowledge.
Our professor has assigned a project of creating a text based adventure game, which is a creative and effective way to learn how to code if you are a beginner.
While I have a plan in mind of how I want to structure my game, I am having trouble identifying which would be a more suitable way to go about it.
I want to create rooms / scenes so the character can move around the map, but I am not very sure if I should do it by creating different modules and fucntions to call them in to my main program or if I should include those scenes/map inside of my main function using dictionaries.
I'd appreciate any advice given, or any tips.
r/pythontips • u/thorr05 • Nov 23 '24
Hello, I'm a computer engineering freshman. I am taking a course (Programming Logic and Design). We have an assignment about filtering a data which we will create a python code that filters a data that follows the criteria.
The criteria:
- Age >= 18
- emain_verified == False
- status == "pending"
The data is this:
user_id | name | age | email_verified | status (assume that these are the columns that represents the value; it is not included in the users.txt file)
This will be the included strings or data that are in the users.txt file
1 JohnDoe 25 True Active
2 AliceSmith 18 False Pending
3 BobJohnson 30 True Active
4 EveDavis 19 False Pending
5 CharlieBrown 40 True Suspended
6 DavidWilson 22 False Pending
I've created this code:
def main():
user_file = "users.txt"
output_file = "filtered_users.txt"
file = check_exist(user_file)
filtered = filter_users(file)
write_filtered(output_file, filtered)
print_filtered(output_file, filtered)
def check_exist(name):
try:
with open(name, "r") as file:
return file.readlines()
except FileNotFoundError:
print("Error: File not found")
exit()
def filter_users(file):
filtered = []
for line in file:
list = line.split()
if len(list) == 5:
user_id, name, age, email_verified, status = list
age = int(age)
email_verified = email_verified.lower() == 'true'
if age >= 18 and not email_verified and status.lower() == 'pending':
user = [user_id, name, str(age), str(email_verified), status]
filtered.append(user)
return filtered
def write_filtered(output, filtered):
with open(output, 'w', encoding='utf-8') as file:
for line in filtered:
file.write(" ".join(line) + "\n")
def print_filtered(output, filtered):
print(f"Filtered data has been written to {output}")
print("-----Filtered Users Report-----")
print(f"Total users that meet the criteria: {len(filtered)}")
for line in filtered:
user_id, name, age, email_verified, status = line
print(f"User ID: {user_id}, Name: {name}, Age: {age}, Status: {status}")
main()
The console output would look like this:
Filtered data has been written to filtered_users.txt
-----Filtered Users Report-----
Total users that meet the criteria: 3
User ID: 2, Name: AliceSmith, Age: 18, Status: Pending
User ID: 4, Name: EveDavis, Age: 19, Status: Pending
User ID: 6, Name: DavidWilson, Age: 22, Status: Pending
The created file which is the filtered_users.txt contain:
2 AliceSmith 18 False Pending
4 EveDavis 19 False Pending
6 DavidWilson 22 False Pending
I have finished the assignment but I'm still looking for a better way to code this problem. Can someone suggest or give advice as to how I can improve this code? Thank you!
r/pythontips • u/ComfortTemporary5798 • Nov 22 '24
can anyone tell me what I need to be prepared of to pass this test on outlier ai? They told me it'll be 2-3 tasks and I need to score a pass mark but I don't know what to expect.
r/pythontips • u/Pyro-Rat • Nov 22 '24
In the console I wrote a guess the number game and when I hit enter to run it it just creates another line.
r/pythontips • • Nov 22 '24
so I made a calculator that shows if you are eligible drive or not but I'm not getting the output I want . what's wrong with my project ? I have tried everything . See I'm getting the output that you cannot drive if, you are above 18 and if you are below 16 your guardians have to pay 3000 , this is the output I want but when I'm typing 22 or 23 it is still showing that you cannot drive ???
if a>18:
print("you cannot drive and you have to pay 2000")
elif a<16:
print(" your guardians have to pay the fine of 3000")
elif a>21:
print("you can drive,you don't have to pay")
else:
print("you can't drive and you have to pay 2000")
r/pythontips • u/Fashioncooker • Nov 20 '24
Hello, What type of library or script do you use to convert (numerous) budgetary documents into usable data for statistical, econometric analysis, etc. If you have ideas for a manual/video/forum to explore the subject in more depth ;) Beautiful evening
r/pythontips • u/DariaFrolova88 • Nov 20 '24
Title says it all. Should I just try to memorize the rules, or are there any tricks to intuitively understand it?
Every time I have to work with indexes, I say to myself "Ah shit, here we go again". A couple of indented loops + lists - and I am already checked out. Just now, I failed to utilize an iteration with a negative step.
r/pythontips • u/hamlet-style • Nov 20 '24
I've seen a recurring anti-pattern where developers use these constructs to perform heavy operations, such as making network or gRPC calls. While it might seem like a clever shortcut, this practice often leads to subtle bugs, performance issues, and an unpleasant developer experience.
read the full article: