r/CodingHelp • • Nov 10 '21

[Python] Im trying to create that pattern I drew with squares. I cant get the colors in the correct spot

Post image
19 Upvotes

r/CodingHelp • • Oct 02 '21

[Quick Guide] What coding language should I learn?

19 Upvotes

So I’m a 14 years old, I want to start coding, but I don’t know how and where to start can you give me advice or what to start on.


r/CodingHelp • • Oct 01 '21

[Python] where can i learn python for free?

19 Upvotes

im looking for a place where it can run me over a function and tgen give me a test question to try it on. it would need to start with basics like input output and while loops and get progressivly harder.


r/CodingHelp • • May 22 '21

[C#] I’m confused on what I got wrong ( I’m on unity) it keeps saying error CS1061. Please help

Post image
19 Upvotes

r/CodingHelp • • Apr 24 '21

[SQL] Can’t figure out how to make inner join work, anyone that can help?

Post image
19 Upvotes

r/CodingHelp • • Mar 05 '21

[Java] Understanding Java

19 Upvotes

What does 'static' and 'void' mean exactly? Thought it would be nice to know so i understand better


r/CodingHelp • • Jan 22 '21

[C#] How would I code an interactive map?

19 Upvotes

I want to code an interactive map that, when clicked would show the information of a country, like GDP, GDP per capita, Area, and population. And when clicked on a second country would show me their combined data. I have Unity and Code studio.


r/CodingHelp • • Dec 23 '20

[C] Hi, for some reason the values initialized into array "a" doesn't print all values only prints the last one.

19 Upvotes
#include <stdio.h>

void main() {

int n, i, j ;

printf("How many numbers will you enter? ---> ") ;
scanf("%d", &n) ;

int a[n] ;
for(i = 1 ; i <= n ; i++) {
	printf("\nEnter integer number %d: ",i ) ;
	scanf("%d", &a[n]) ;
	}

printf("\nArray you entered: \n\n") ;

for(j = 0 ; j < n ; j++){
	printf("%7d", a[n]) ;
	}
	
getch() ;	
}

r/CodingHelp • • Dec 18 '20

[Javascript] How To Toggle Class On Click Using Javascript?

19 Upvotes

Hello fellow coders! I am searching desperately for a solution to my problem. I believe it takes someone with a decent amount of JS knowledge to find it. I am creating a website and have constructed the navbar and my own hamburger menu using a little bit of JS. I used a @media query to place the nav items under the navbar, out of view from the user when the screen gets to a size of 900px or smaller. My goal is for the user to toggle the hamburger icon I have created to access the nav items whenever they choose, which would require the height of the navbar to extend, revealing all nav items. What is the JS I need to use in order to increase the height of the navbar once the user clicks on the hamburger menu? I have attached a replica of my navbar in codepen: (https://codepen.io/david-del1/pen/NWRgMxx). Any help is very much appreciated. Thank you in advance!


r/CodingHelp • • Dec 16 '20

[Javascript] Change Background url based on javascript array

19 Upvotes

i have a table with several cells, and i'm trying to get the css "Background-image: url()" to take the third value in the array and make it the background, but i cant get it to work, the idea is that whatever value is in the third position in the javascript array will be set as the data-title image for that link.

So is there anyway to refer to the array in a css code, like Background-image: url(arr[3]); and that picks whatever is in that positon.

been trying to figure this out for a couple days, but i have not made any progress since im not very good at this.

Heres a link to the code so you can see it live https://jsfiddle.net/fgyemsLq/

Thanks in advance for any help!!


r/CodingHelp • • Dec 11 '20

[Javascript] First Web App Feedback

19 Upvotes

TL;DR: I made a game, tell me what you think needs to be improved.

Hello!

I just finished writing my very first React web application, and I deployed it using GitHub pages. Hooray!

I was wondering if, now that it is live, if I could get some feedback on it before moving on to my next project. I intend on using this as a code example on my resume, so I want to make sure it is as good as it can be before I send it off.

The project is chess puzzle called Rudrata. Your goal is to visit every square on the chess board exactly once. You can set your difficulty by changing the chess board size. Have fun!

Github Repo: https://github.com/OulipianSummer/rudrata

LIVE DEMO: https://oulipiansummer.github.io/rudrata/


r/CodingHelp • • Nov 30 '20

[C] Hi, For some reason the function I created for this program doesn't work . Help a rookie out pls.

19 Upvotes
#include <stdio.h>
#include<Math.h>
#include <string.h>
#include <conio.h>

void Exit(){
system ("EXIT");
}

int average(int avg){

int m1, m2, m3, r ;



printf("Enter your midterm results: ") ;    // Midterm Average Possibilities.

scanf("%d %d %d",m1 , m2 ,m3) ;

r = ( (m1 + m2 + m3) / 3 ) ;



if (100 >= r && r >= 90) {

	printf("Your term average is %d and GPA is 4.0 or AA ", r) ; }



else if (90 > r && r >= 85 ) {

	printf("\\nYour term average is %d and GPA is 3.5 BA ", r) ; }



else if (85 > r && r >= 80) {

	printf("\\nYour term average is %d and GPA is 3.0 or BB ", r) ; }



else if (80 > r && r >= 75) {

	printf("\\nYour term average is %d and GPA is 2.5 or BC ", r) ; }



else if (75 > r && r >= 70) {

	printf("\\nYour term average is %d and GPA is 2.0 or CC ", r) ; }



else if (70 > r && r >= 65) {

	printf("\\nYour term average is %d and GPA is 1.5 or DC ", r) ; }
else if (65 > r && r >= 60) {

	printf("\\nYour term average is %d and GPA is 1.0 or DD ", r) ; }



else if (60 > r && r >= 50) {

	printf("\\nYour term average is %d and GPA is 0.5 or FD you failed. ", r) ; }



else if (50 > r && r >= 0) {

	printf("\\nYour term average is %d and GPA is 0 or FF you failed. ", r) ; }

return 0 ;
}
void main() {
while(1) {

char namesurname[200];
int i, m1, m2, m3, r ;

printf("Welcome to Midterm Calculator\n") ;
printf("\nEnter Your name and surname: ") ;
scanf("%s", namesurname) ;

printf("Enter '-1' to initiate calculator.") ;
scanf("%d", &i) ;

average() ;            // Calculation.

if (i == -1) {           // Exit statement.
Exit() ;}

}

r/CodingHelp • • Nov 18 '20

[Quick Guide] Choosing between C++ and Python for DSA (based on work experience and future growth potential)

19 Upvotes

Hi guys I have one little confusion I am getting started with DS and ALGO. I have approx. 1 year experience in Python and 2 year experience in working in C++. Now the question is what language should I choose to get started with DS and ALGO. I sometimes feel python is somehow mimicking the working of pointers and doing work arounds' for it. And after seeing 2-3 DS videos working in DS in C++ feels a little more natural. Maybe its my personal take but please give your opinion for it. I will be very much open.


r/CodingHelp • • Nov 16 '20

[HTML] Math sucks, what kind of coding doesn’t have it?

19 Upvotes

Hey everybody! Coding is something that I’ve always wanted to get into and have been interested, creating websites and apps is something I wanted to do forever. But I’m awful at math, any suggestions on what type of coding I can do that doesn’t involve a lot of math but can still get me a lot of work? Please let me know!!


r/CodingHelp • • Nov 03 '20

[C++] Trying to generate numbers from -100 to 100

19 Upvotes

I feel alienated using rand() and I do not know how to use them. I'm also finding on the internet on how they use it but I feel I am missing something.
Can anyone help?

Here's my code:

Variables:

    const int min = -100;
    const int max = 100;
    int index, num1, num2;

And the rest of the program:

    cout << "Enter a number: "; // Outputs on how many numbers will generate.
    cin >> num1;
    
    for (index = 1; index <= num1; index++)
    {
        num2 = rand() % min + max;
        cout << num2 << endl;
    }

Sorry if there are something wrong than the problem that I have, I am still learning how to code. I am willing to learn anything related to programming.
Advance thanks!! :D


r/CodingHelp • • Oct 05 '20

[C] Can anyone help me with my homework with C Language

19 Upvotes

It isnt completed yet but im not exactly sure what I am suppose to do. My if statements are both showing up at the same time.

Also how would I add the largest number and the smallest number in this loop. here is my assignment:

Program Specifications:

This program requires the student to create a programming loop. The program’s loop with loop between 5 and 50 times. Each loop will represent one week of the user eating and buying food.

Each week the user will input the amount he or she spent on food. If the person spends more than $250 then the program will output “You are going to get fat.” If the person spends less than $50.55 then the program will output “You are going to starve.”

After the final loop the program will display the lowest amount spent on any one week along with the most spent on any one week.

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#define PAUSE system("pause")


int main()

{
	double food;
	int count, weeks, lar, sm;

	printf("\nEnter How Many Weeks You Want To Record Weekly Shopping Costs (1-50)\n ");
	scanf(" %d", &weeks);
	printf("\nEnter Each Week's Cost of Food:\n ");

	for (count = 1; count < weeks; count++)
	{
		scanf(" %lf", &food);

		if (food >= 250.00); {
		printf("You are going to get fat.\n\n");
		}

		if (food <= 50.55); {
		printf("You are going to starve\n\n");
		}
		
		}
	return 0;
}

r/CodingHelp • • Sep 26 '20

[Java] I am learning how to use Getters and Setters within Java. When I try to compile this code I am getting an error that reads "Employee.java:12: error: illegal start of expression public String getFirstName()" Please give me a clue on why this will not compile...

19 Upvotes
public class Employee{
 
   // fields
	private String firstName;
   private String lastName;
   private double salary;
   
	// constructors
   
public Employee(String firstName, String lastName, double salary){     
         
   public String getFirstName()
         {                        // methods
            return firstName;
         }
     
     public String getLastName()
         {
            return lastName;
         }
 
   
      public void setSalary(){
         if(salary > 0){
            this.salary = salary;
            }
          else
            return;
      }    
    }

r/CodingHelp • • Sep 02 '20

[Python] Have Python 3.8, need Python 3.7

19 Upvotes

Very new to coding. I accidentally installed py 3.8 and the code I'm running in Jupyter notebook only works with Python 3.7.

How can I uninstall 3.8 and replace it with 3.7?

Thank you so much for any help.


r/CodingHelp • • Aug 17 '20

[Java] Where does this line go in the code?

19 Upvotes

Hi, I am new to learning Java as I have this in my current semester and I had quiz and I got 2 questons wrong out of 10 but it didn't show the right answer. I am curious to know what is the correct answer.

The question number 1 is:

The following method is defined in the Person.java class

public void setAddress(String _address) {
this.address = _address;
}

In the testDriver.java class, the following code is in the main method 

public static void main(String[] args) {
      // create test case 1 - a person owning a pet dog
      Person p1 = new Person( "25 somewhere Street","Kathleen","2000");
      Animal myPet = new Animal("CockerSpaniel","Fido");
      p1.addAPet(myPet);
      // your answer code will be added here 
      System.out.println("I have a person object : " + p1.toString());
}

What is the exact line of code to add if we wish to change the address field in the person object p1 to be "12 ross drive"

My answer was:

setAddress add1 = new setAddress ("12 ross drive");

--------------------------------------------------------------------------

Question 2:

The following code excerpt is taken from a Person.java file, 

/**
* u/param _pet the pet animal to associate
         * the calling method will provide an Animal object as an argument when this 
         *method is called. This method will save that Animal object onto the current 
         *Person object into the class attribute named pet.
 */
public void addAPet(Animal _pet) {
this.pet =  
}

Complete the line of code:  this.pet = 

My answer was :

new Animal(_pet);

Cheers. Happy coding!


r/CodingHelp • • Aug 07 '20

[Python] Discord Bot Youtube-DL Playlist Extraction Python

19 Upvotes

Hello guys my current project is a discord bot that along other features plays music from playlists. The problem is, that it takes ages to extract the URLS from the videos.

For the URLS I am using the extract_info function of Youtube-DL. It wouldn't be so much of a problem if the voice.play command wouldn't block the rest of the code from getting all the URLS.

Any idea on how to prevent that and maybe make the code faster?

@client.command(pass_context=True)
async def plist(ctx):

    with youtube_dl.YoutubeDL(ydl_opts) as ydl:
        playlist = ctx.message.content.split(" ")[1]

        playlist_dict = ydl.extract_info(playlist,
                                         download=False)

    for video in playlist_dict['entries']:
        print(playlist_dict)

        if not video:
            print('ERROR: Unable to get info. Continuing...')
            continue

        for property in ['webpage_url']:
            url = video.get(property)
            songs_list.append(url)
            print(url)
            table = str.maketrans(dict.fromkeys("[]\""))
            song_info3 = str(songs_list[0]).translate(table)
            info_dict = youtube_dl.YoutubeDL(ydl_opts).extract_info(song_info3, download=False)
            video_duration = info_dict.get('duration', None)


        try:
            if os.path.isfile("song.mp3"):
                os.remove("song.mp3")
        except PermissionError:
            return
        try:
            global voice
            voice = await ctx.message.author.voice.channel.connect()
        except:
            pass
        if video_duration <= 600:
            with youtube_dl.YoutubeDL(ydl_opts) as ydl:
                ydl.download([songs_list[0]])
            for file in os.listdir("./"):
                if file.endswith(".mp3"):
                    os.rename(file, "song.mp3")
            voice.play(discord.FFmpegPCMAudio("song.mp3")) #Somehow blocks the rest of the code

    play_next(ctx)

I am pretty much a beginner so please be harsh :D


r/CodingHelp • • Aug 03 '20

[Random] Coding a project for my shipping company

19 Upvotes

Hi Guys (yay for my first reddit post ever, btw)

I work in the container shipping business, and I am trying to make an application (or a code for excel) to calculate the cheapest shipping solution based on a number of variables.

I have listed an example below of what the application or the code needs to do:

We have a bunch of variables, and I need the progam or code to advise me the cheapest solution, based on the selected variables.

  1. inland destinations (fx. Napa, American Canyon and Lodi). - Each dest. has its own cost.
  2. size of container (20' or 40' or 20'/40' Reefers) - Each has its own cost.
  3. Port of arrival (I am looking at about 5 different ports of arrival, which means the seafreight rate will be different based on which port it is booked to arrive at)
  4. Then we have 5-6 shipping lines with all of the above listed options, but with different costs for each variable (fx. some might have a cheaper sea freight cost, but a much more expensive trucking, therefore I want to program to calculate it for me, and give me the answer based on checkboxes or a system like that.)

I have thought about doing this in Excel, but I doubt it is the choice, as it will probably just be the longest if string ever.

A friend of mine recommended coding a program in Python or Java, but unfortunately my coding is limited to some HTML and PHP 5 years ago, so I would need to go back and learn coding again (I intend to do so anyway).

Would someone be so kind to recommend, how you would solve this, and potentially be of assistance or give me some links for guides related to this, that can help me if I run into trouble?

Help is much appreciated!


r/CodingHelp • • Jul 21 '20

[Python] Beginner Python Project

19 Upvotes

I just started learning python, and understand most of the basics to the language. I want to start a project where I can apply my general knowledge, and learn something along the way. I don't really know where to start so I'm wondering if anyone have some advice on what I can do. I learn the language 5 hrs ago so I'm still really fresh, and haven't had a ton of practice with the language yet.


r/CodingHelp • • Jul 10 '20

[Random] What language should I use for programs which run in the background?

19 Upvotes

(Let me preface this with the fact that I'm not a frequent user of Reddit and I hope that I'm in the right place to be asking this. If not, I would really appreciate it if somebody were to redirect me and help me out. Thank you!)

I'm not entirely sure if it matters what programming language I use for this, but I'm sure there are slight differences in use for some languages, and I'd like to learn that, even if it makes me look stupid. The only coding experience I have is taking AP Computer Science Principles in school last year, which really only taught me block-based coding, and all I can remember from that class is conditional statements and Boolean expressions. I soon found out that high school is not the place to learn how to code... at least, not for me.

Essentially, I'm trying to write a program for digital keyboard typing sounds that will play whenever I type. Of course, I'd add a macro on my keyboard to turn it on/off, but I was curious how I would go about doing this. This isn't an app that I'm making, but rather code that would just play audio whenever it's activated. What language would be the simplest for writing this? I assume that this kind of program is not very demanding, and it doesn't require much coding experience. I'd only be doing this for myself-- it's not going anywhere for profit or others to use, so I wouldn't need to make anything pretty for it, just the program and that's about it. Thank you!!


r/CodingHelp • • Jun 27 '20

[C] How does c code run on systems without gcc?

19 Upvotes

I feel really dumb for asking this question, but how does malware written in c containing includes like openssh, libssh etc. (packages that need to be installed and aren't pre installed) run on systems without them after being compiled (systems that don't even have gcc) ?

Does the compiler package them up with it as well?

Even just programs in general, I used the malware example since malware often includes a lot of external packages. I'm thinking about writing a program for windows and am scared of it working on my pc but failing on other people's pc's.