/r/learnprogramming
A subreddit for all questions related to programming in any language.
If you need help debugging, you must include:
See debugging question guidelines for more info.
Many conceptual questions have already been asked and answered. Read our FAQ and search old posts before asking your question. If your question is similar to one in the FAQ, explain how it's different.
See conceptual questions guidelines for more info.
Follow reddiquette: behave professionally and civilly at all times. Communicate to others the same way you would at your workplace. Disagreement and technical critiques are ok, but personal attacks are not.
Abusive, racist, or derogatory comments are absolutely not tolerated.
See our policies on acceptable speech and conduct for more details.
When posting some resource or tutorial you've made, you must follow our self-promotion policies.
In short, your posting history should not be predominantly self-promotional and your resource should be high-quality and complete. Your post should not "feel spammy".
Distinguishing between tasteless and tasteful self-promotion is inherently subjective. When in doubt, message the mods and ask them to review your post.
Self promotion from first time posters without prior participation in the subreddit is explicitly forbidden.
Do not post questions that are completely unrelated to programming, software engineering, and related fields. Tech support and hardware recommendation questions count as "completely unrelated".
Questions that straddle the line between learning programming and learning other tech topics are ok: we don't expect beginners to know how exactly to categorize their question.
See our policies on allowed topics for more details.
Do not post questions that are an exact duplicate of something already answered in the FAQ.
If your question is similar to an existing FAQ question, you MUST cite which part of the FAQ you looked at and what exactly you want clarification on.
Do not delete your post! Your problem may be solved, but others who have similar problems in the future could benefit from the solution/discussion in the thread.
Use the "solved" flair instead.
Do not request reviews for, promote, or showcase some app or website you've written. This is a subreddit for learning programming, not a "critique my project" or "advertise my project" subreddit.
Asking for code reviews is ok as long as you follow the relevant policies. In short, link to only your code and be specific about what you want feedback on. Do not include a link to a final product or to a demo in your post.
You may not ask for or offer payment of any kind (monetary or otherwise) when giving or receiving help.
In particular, it is not appropriate to offer a reward, bounty, or bribe to try and expedite answers to your question, nor is it appropriate to offer to pay somebody to do your work or homework for you.
All links must link directly to the destination page. Do not use URL shorteners, referral links or click-trackers. Do not link to some intermediary page that contains mostly only a link to the actual page and no additional value.
For example, linking to some tweet or some half-hearted blog post which links to the page is not ok; but linking to a tweet with interesting replies or to a blog post that does some extra analysis is.
Udemy coupon links are ok: the discount adds "additional value".
Do not ask for help doing anything illegal or unethical. Do not suggest or help somebody do something illegal or unethical.
This includes piracy: asking for or posting links to pirated material is strictly forbidden and can result in an instant and permanent ban.
Trying to circumvent the terms of services of a website also counts as unethical behavior.
Do not ask for or post a complete solution to a problem.
When working on a problem, try solving it on your own first and ask for help on specific parts you're stuck with.
If you're helping someone, focus on helping OP make forward progress: link to docs, unblock misconceptions, give examples, teach general techniques, ask leading questions, give hints, but no direct solutions.
See our guidelines on offering help for more details.
Ask your questions right here in the open subreddit. Show what you have tried and tell us exactly where you got stuck.
We want to keep all discussion inside the open subreddit so that more people can chime in and help as well as benefit from the help given.
We also do not encourage help via DM for the same reasons - that more people can benefit
Do not ask easily googleable questions or questions that are covered in the documentation.
This subreddit is not a proxy for documentation or google.
We do require effort and demonstration of effort.
This includes "how do I?" questions
/r/learnprogramming
I'm currently creating a simple social media platform. Each user in the application will have a unique username, which will be stored in a MySQL database. I'm just stuck choosing between two options:
I can create a React Redux slice to store the current user, and whenever I need to display the username anywhere, I can simply use the username that I recieve from React Redux.
I can take the displayName from the Firebase authenticated user, and display that name as the username.
The only difference between these 2 options really is that the React Redux method just adds a little bit more complexity. Obviously whenever the user creates a post or comment, I will be searching the database for their username, but just for user's frontend, is it a viable method to use displayName? Is the user able to change this property?
Hey, i'm preparing for my interviews/jobs and graduating this may. Like a leetcode session 2hours/day.
we can discuss some interesting problems and can get good at cp and programming. If interested dm me.
Lets connect.
Thanks
Hi, I'm making a music website for a college project, and currently I'm drawing class diagram for MVC and I have some questions. I have read that one controller can have multiple views, so I was thinking of having a UserController to handle views like SignUp, LogIn, ChangeProfile, etc. When I look at the Internet on how to implement this, most of the time I would only see the example where they use 1 controller - 1 view. So my questions are, for example in the view for SignUp, giving that the attributes are username, password, email, verificationCode, what should the methods in this view class be? Since controller have many views, how would it know what views it is dealing with, how would view know which controller it sending user input to? And how would controller update the view after that. I'm asking these questions because I haven't really built real application using MVC architecture before and some obvious things may not seem plausible to me. Thank you for you guys help.
The following is the code I need to translate.
void swap(int v[], int k) {
int temp;
temp = v[k];
v[k] = v[k+1];
v[k+1] = temp;
}
void sort (int v[], int n) {
int i, j;
for (i = 0; i < n; i += 1) {
for (j = i – 1; j >= 0 && v[j] > v[j + 1]; j--) {
swap(v,j);
}
}
}
int main() {
int A[10] = {7, 42, 0, 27, 16, 8, 4, 15, 31, 45};
sort(A, 10);
return 0;
}
how do i get into software engineer?
seriously, i just graduated with bachelor in Tourism, and i wanted to be software engineer
do i need another bachelor? i'm willing to put in the hours and effort
Hi there, I’ve recently started to learn how to code on my own and I enjoy it, however, I am quite lost on what direction to go!
Does anyone have any advice on what path to go down? As in web dev/app dev/what languages to learn/etc.
I truly appreciate anyone’s help and am open to trying different paths, I’d just like some input from more experienced people.
Thank you!
Title. I’m having a hard time understanding the differences.
I created a simple program that I want to share with other people for use, but the thing is that whenever I upload the files for the program on Google Drive or anywhere else, either the browser or antiviruses will detect the exe file as a virus and will refuse to download. From what I've been seeing online, I would need to do code signing for the program, but it would cost money to do so. I don't plan on charging people for the program, so I don't want to do that. Is there a way I could have the program up for use for people with no coding experience, whether it be online or whatnot? I would try to use Replit as a way to share the program, but the thing is that the program is meant to allow the user to copy and paste text into a text file so the program can read it to make calculations. On Replit, it doesn't allow the user to edit any files, even the txt file.
For context, I’m a CS student in my first year of CS classes. I’ve dabbled with scratch, swift playgrounds, and python but about half way in to my python bootcamp I decided it would probably be better to spend that time and effort getting the piece of paper while I was at it, because I genuinely enjoy it. I was hoping things like the ins and outs of IDE’s would be covered in my fundamentals class, but they aren’t. The class uses Java with an online and interactive textbook that’s great for teaching you Java and writing logic, but then for projects you’re just sent to download JDK, Netbeans, and given .jar and .java files to open and edit. Which is fine enough, I just feel like it would benefit me to know how to open and start a new project from scratch, how and where is the best way to save that file so I can open it on both my desktop & laptop, etc. Are there any resources anyone could point me toward to get a better grasp on things like that, rather than logic exercises?
As you guys may know from my other posts, I have been self teaching myself python and basically programming. I’m currently in the middle of a hard dilemma.
S, im a 3rd year university student in japan currently majoring in environmental science (i know its nothing related to cs etc). However I started losing interest in my major and picked up programming early this year and I figured out that I wanted to be a software dev or any tech sector jobs in the future (after I finished my uni).
So basically the dilemma is that should I change uni and get a CS degree or shud i just finish my study in my current uni, while learning programming on my own, get the degree and hopefully got an intern and a job.
Any advice will be appreciated! Cuz im really lost on what to do. TIA
TL;DR Studying a different major in a japanese uni, but wanting to have a tech job in the future. Shud i change uni to get a CS degree or just muscle it through with self learning.
I want to tryout some programming games, so i can chill and play something which is still productive. The difficulty could be easy since I’m not even coding for a year.
Does anyone have some recommendations, and pls let it be something i can play on mac. And i’m not interested in CSS and HTML.
I've been learning how to code for about a year now, give or take. I'm learned JS and I know quite a bit about React from what I watch in tutorials but outside of this, I have no road since I don't go to college to learn programming and I have no idea as to what projects I'm supposed to do or how I would even go about getting a job. What projects are employers looking for? Or what technologies are the most relevant so I can build something using those. Do I need to go all out and learn MERN because I've heard people say that learning MERN isn't necessary if you're going in as a junior developer. If that's the case, I could theoretically already get a job, I just need to know what projects to build. Also, what is a portfolio? Is it just a site that links to all of my projects? Where do I apply? Just to LinkedIn? I have so many questions since I'm doing this all on my own and I don't know anyone who does coding. You can post below what projects you built to get your first job. Thanks in advance
e.g. Windows OS has accents and Dark and Light Mode. I want to independently skin my window from the Operating System. How do?
Let's say this is mostly language agnostic, apart from interfacing with the Windows API, which begs the real question - is there an A PI to control this?
I am working on an interactive website to act as a "portfolio" for my projects now and into the future. All done in CodeSpaces using HTML/JS/CSS. Would love to know what bad habits you may see, bad choices etc.
Website - Here is the link
Repo - Here is the link
I have been working on this for about 2-3 days now and have never touched HTML, CSS, or Javascript so please go easy on me. I would very much like constructive feedback.
Right off the bat I know that:
Formatting is horrendous - different screen sizes alter the experience and needs to be fixed
Formatting in general - weird spacings where there shouldn't be (again dependent on screen size)
More depth and "cleanliness" on the different pages (and keep consistency)
I know my code is messy and working on being more tidy in this area is a must (learned a few days in it is best to have separate files for separate pages and tasks. I started having everything on one and realized how bad and silly that was.
I know there may be too many elements going on at once. Each one is to try and demonstrate a different level of complexity (ie. the shapes when you hover over move, the Works page ideally those would be cards rotating of different projects etc.)
Again, I am new. I am still forming habits and developing skills so I know this first go is going to be garbage... but it's my garbage and I intend to improve it over time. :)
Hello! I wanted to do a personal project that involves programming and circuitry (like Arduino) and will help like a group of people.
I am currently a high schooler so I don’t have access to a lot of expensive resources but I would like to learn more ways to apply my coding and circuitry knowledge to physical projects that are catered to a community (like high schoolers, elderly people, or even like a smaller group).
I am not sure if this is the right sub to ask for ideas but I hope to learn/do more! Thank you! :)
I've written blog posts about Linear Congruential Generators and Lazy Cartesian Products. It's hard for me to know if they are understandable and readable for myself. If anyone DMs me, I'll send you the links and you can learn about some really cool algorithms. I think that if you've taken a couple of Python courses, you'll probably be able to follow them but also learn something.
It's a Series object like this, it's obtained from a csv file but [x,y] is just a string, not a list
0 [x]
1 [x,y]
2 [x,z]
I want the number of x,y,z. In this case it would be x=3, y=1, z=1
My end goal is to make a box plot with x,y,z as the categories and have my y axis display the count of how frequently each of x,y,z occurs, something like this
plt.bar(['x','y','z'], [#instert the count of x,y,z])
for anyone wondering, the solution was
df.str.split(',').explode().tolist()
Hi,
If a customer is talking to an AI chatbot over the phone, I want to be able to pass them onto a human if they seem to be distressed or are struggling with communicating with the AI. I'm currently looking into 2 options:
I don't know much about this stuff and unfortunately have no idea how to go about using non verbal elements.
Does anyone have any suggestions on what resources exist for implementing these?
Any help would be appreciated!
Thanks
program should take integer inputs from user and once a 0 has been entered read back the lowest number entered besides 0.
I can't figure out whats wrong with my code
.data
prompt: .asciiz "Enter an integer : "
output: .asciiz "The smallest number is "
smallest: .word
.text
loop:
#get user input
la $a0, prompt
li $v0, 4
syscall
#store user input
li $v0, 5
syscall
move $t2, $v0
beqz $t2, exit
slt $t5, $t0, $t2
movz $t0, $t2, $t5
j loop
exit:
sw $t2, smallest # put $t1 into the label smallest
la $a0, output
li $v0, 4
syscall
lw $a0, smallest
li $v0, 1
syscall
#end program
li $v0,10
syscall
I'm a beginner to web dev and I keep finding out random things while trying to make my own websites that don't make sense to me. I also feel that the things are so obvious that there is little info on the topic, and what I don't understand is kind of hard to describe when searching on google. Is there a website specifically for simple dumb questions or should I just get a coding teacher?
I am working in pycharm and have linked my github. I am fairly new to this particular set up, and I am working with others and so I don't want to mess it up.
B
, that I am currently working on.A
, that is our main "dev" branch.I want overwrite A
with what I am currently doing in B
.
What exactly do I do? I see all these different features but this is all a bit confusing.
Hello,
I'm trying to build out a project by using C# / .NET Core + Vue for learning purposes. My idea is to create a .NET Web API to handle a shared session type of project where users can click create your own session to host or join someone's session.
When someone creates their own session, I can then generate a type of password or session ID that others can join in and they can see whos in the same session with them by displaying their name or user ID. I'm also learning Vue for the front end. My question is what kind of services provide what I'm looking for?
My best guess was maybe Firebase / Supabase for authentication but I guess I'm not entirely sure what to even google.
Thank you for your advice and tips, I appreciate it!
So I have a python script that does web scraping using selenium then some simple processing, my idea is to you the web mobile app clips and to create a simple website that runs the python script on the backend. I would be the only one using this so i want to try and keep it free if possible, any services you guys can vouch for to allow me to do this?
Hello guys!
I've got a challenge at my university to build a model that extracts products from. 500+ furniture stores.
Here are the guidelines:"## Guidelines
A good approach that works well with such extraction problems is to create a NER (Named Entity Recognition) model and train it to find your entities (you have one entity, ‘PRODUCT’).
- In order to create such a model you need training data, you can also extract that from the input pages.
- Crawl ~100 pages from the list above & extract the text from it.
- Find a way to tag some sample products from these texts.
- Train a new model from the examples you just made.
- Use it to extract product names from some new, unseen pages.
Please use any programming language, toolset or libraries you're comfortable with or find necessary, especially if you know it will be better or more interesting.
We recommend using the Transformer architecture from the [**sparknlp**]874df20d1d77) library or the huggingface [**transformers**]( library."
I have little experience with web crawling. I`m not that scared about the NER part, rather then crawling the ~100 pages in order to train my model. I have tried to scrape with beautifulsoup but I don't know how to make it so I don't have to input manually the site selectors in order to get the correct product name.
If you have any suggestions, please let me know <3
I have noticed that a lot of mistakes that I make when working on programming problems just stems from me either over complicating the problem (example: adding a for loop when its actually not needed when dealing with arrays, or just something else silly).
The most of the time when I struggle so badly on a problem that I end up looking up the solution I just feel dumb because the solution was so much simpler than what I was trying to do.
How do I go about to improving this?
I've been on this for an entire afternoon and am so done. idk if anyone can help me but idk what else to do. I truly have checked everywhere, including looking info both on vscode and codium, asking chatGPT, countless forums... the problem is just too specific, and codium too little used an supported. But I also simply don't want to use vscode, plain and simple, so I'm very stuck.
Here's the situation: I'm coding C++, Pop_OS 22.04, and am trying to use GTKmm for the first time. The way I currently have vsc set up is that I use the clangd extension for syntax editing and catching errors, and then i simply have custom build tasks that run "make" on my current folder to compile and link my project. Everything is in one folder and the project itself isn't very big, consisting of about 7 modules. But I do need GTKmm and that's my current problem: it's properly installed on my system and everything works perfectly if I run make from the project directory in the terminal. But if I try to run make on that same directory from vscodium, whether it's through my task or through a terminal, it gives an an error, bc it can't find GTKmm4:
project.cc:1:10: fatal error: gtkmm.h: No such file or directory 1 | #include <gtkmm.h> | ^~~~~~~~~ compilation terminated. make: *** [Makefile:14: simple.o] Error 1
Similarly, clangd is now rendered useless as it also cannot find the gtk header, and thus is constantely signaling errors where there are none. How can I solve this? I've gone as far as creating a copy of all the necessary .pc files and added them to a different pkgconfig folder (because VSCodium kept telling me it was unable to find the ones my terminal accesses just fine), as well as making sure to include the folder containing gtkmm's header under c_cpp_properties.json (tho i can't imagine this does anything, seeing as all I'm doing is running make?)
I simply don't know what else to do. It seems like vscodium just doesn't "see" (for lack of a better word) the folders that my terminal's makefile does. How can this be?
I am trying to call an API from Swagger on Microsoft Visual Studio, but I am getting nothing returned. The API is called CityReview, and it takes City as an input to run a stored procedure on MS SQL Server. I am attempting to run the API by going to /AToday?City=Chicago but nothing is returning. HTML
@ page
@ model RateMyAsthma.Pages.ATodayModel
@{
var City = HttpContext.Request.Query["City"];
}
<head>
//...
</head>
<body>
<h1>Today reviews for:</h1>
<h2 id="cityName" style="visibility: hidden;"></h2>
<div id="cityRating" style="visibility: hidden;"></div>
<script type="module">
displayCityReviews(@City);
</script>
</body>
JavaScript
async function displayCityReviews(City) {
const response = await fetch(`https://localhost:7070/api/CityReview/${City}`)
const data = await response.json();
document.getElementById('cityName').innerHTML = data[0].city;
document.getElementById('cityName').style.visbility = "visbile";
document.getElementById('cityRating').innerHTML = data[0].rating;
document.getElementById('cityRating').style.visbility = "visible";
}
Hi people, I want to learn SFML. Any suggestions?
I have problems opening an image from binary data and displaying it in a CTk window. I recieve "pyimage3 doesnt exist" error.
def flags():
global gamew
global play
global capital_entry
global button
global started
started=0
play=True
gamew=ctk.CTk()
gamew.protocol("WM_DELETE_WINDOW",close_game)
gamew.title("Flags")
gamew.geometry("450x450")
label=ctk.CTkLabel(gamew,text="Flags",text_color="white",corner_radius=10,height=10,width=400)
label.configure(font=("TkDefaultFont", 50))
label.pack()
button = ctk.CTkButton(gamew, text="Start",command=enter_flags,width=200,height=40)
button.pack(pady=30)
gamew.mainloop()
def b_recv():
len=my_socket.recv(10).decode()
return my_socket.recv(int(len))
def enter_flags():
global gamew
global s_button
global started
global label
global ans
global image
global photo
started += 1
if started == 1:
button.destroy()
send("flags")
binary_data = b_recv()
try:
# Create the PhotoImage object
image = Image.open(BytesIO(binary_data))
photo = ImageTk.PhotoImage(image)
# Create a label and display the image
label = ctk.CTkLabel(gamew, image=photo)
label.image_ref = photo # Keep a reference to prevent garbage collection
label.pack()
except Exception as e:
print("Error loading image:", e)
Keep getting the “Type ‘()’ cannot conform to ‘View’” error at ’numbers.append(4).’ What am I doing wrong here?
import SwiftUI
struct ContentView: View { var body: some View {
var numbers = [1, 2, 3]
numbers.append(4)
VStack {
if numbers.count == 3 {
Text("Happy birthday!")
} else {
Text("Not Happy Birthday 😔")
}
}
}
}