• Breaking News

    Thursday, March 21, 2019

    28 and looking to move from inside sales to programming learn programming

    28 and looking to move from inside sales to programming learn programming


    28 and looking to move from inside sales to programming

    Posted: 21 Mar 2019 06:40 AM PDT

    Hi /r/learnprogramming friends I have taken an interest in the last few months in the idea of changing my career path and learning coding. I have started using FCC and am moving along at a slow and steady pace. I know success in this doesn't come overnight and requires some tenacity. Getting to it once per week right now is kind of a hurdle. I am trying daily to motivate myself to find an extra hour in every day to get some lessons in. I just need to keep with it and I know soon enough I'll have the course completed.

    I am coming from a sales background. I used to have a pretty broken up work schedule. Recently, I took an inside sales job with an internet/technology vendor. After 6 months of a M-F commute, I am sold on the idea of working from home. I am also sold on a new career path. Programming looks like a good choice for independence and work-from-home opportunities.

    I'm wondering what the programming job market looks like currently for remote work opportunities. I live in rural Ohio and I'd like to work without a commute. My question is if anyone has had luck finding remote programming work with success. I would also appreciate any tips or pointers on changing careers moving into programming. Once I have some projects under my belt, I plan on starting a Github portfolio and sharing it with prospective employers. Like I said, I know it won't be an overnight thing, but this is my goal and I understand that work needs to be done to get there.

    Thanks in advance for your responses!

    submitted by /u/arbowles09
    [link] [comments]

    Help with an interview question I could not answer.

    Posted: 21 Mar 2019 11:47 AM PDT

    I went to my first frontend developer interview and of course I was nervous but they asked me a question that I could not answer.

    It went like this...

    "Using HTML and CSS without JavaScript how would you take a list of say 500 people and sort them alphabetically and only show one at a time. Then make a buttons so everytime the button is clicked it goes to the next person."

    When I was just staring with a blank face after a minute he gave me a hint saying something about using the z-index. I know about the z-index and how it can layer over one another but I didn't get how it worked with this question. How would you answer this?!

    Thanks in advance!

    submitted by /u/blockchain_dev
    [link] [comments]

    I created a game in javascript where the player has to catch pancakes that fall. For some reason, the speed of each pancake increases at the beginning of each level and then returns to normal, and I have no idea why! thank you!

    Posted: 21 Mar 2019 06:40 PM PDT

    Edit: so the pancake is no longer speeding up at the beginning of the next level. However, the logic behind my ms speed variable was incorrect and it seems that the loop doesnt speed up from 10 to anything less than ten milliseconds. Any advice? Running the same loop fall() multiple times makes it laggy.

    Working code that is runnable (USE THE LEFT AND RIGHT ARROW BUTTONS TO MOVE PAN!!!):

    https://studio.code.org/projects/applab/EHndphv5YUIpqWS2aQR-N_txs9b2nH3zG5OXqo9Yq4g

    Hello, I am in an introductory computer science class and we have to make a program. Mine is a game where you catch pancakes as they are falling. In the function fall(), I have a timed loop where a pancake image falls. I normally assigned it a variable, ms, that changes the number of milliseconds, so as you progress, the pancakes fall faster. However, I noticed that at the beginning of every new level, the first pancake to fall is much faster. I replaced the ms in the timed loop with a constant 2, and it still happens at the beginning of each new level, as seen in the video. Why is this happening and what can I do? Thank you for any help. I attached my code below, and the bolded portion is what should be necessary.

    hideElement("scorepositive");

    hideElement("scorenegative");

    var colors=[];

    function changecolor() {

    colors=rgb(randomNumber(0,255 ),randomNumber(0,255 ),randomNumber(0,255 ),0.32);

    }

    changecolor();

    setProperty("screen1", "background-color",colors );

    setPosition("pan", 80, 300, 200,200);

    setImageURL("pan", "frying_pan_PNG8360.png");

    var pancakeimages=["kisspng-banana-pancakes-scrambled-eggs-breakfast-ihop-pancake-5abe8257eb8262.1142069015224346479647.png", "pancake_PNG1071.png","pancakge4.png","pancake5.png"];

    var x;

    var y;

    var xpan = 45;

    var ypan=320;

    var p=0;

    var score=0;

    var level =1;

    //ms is the time in milliseconds the fall function waits before looping.

    var ms;

    findms();

    function findms() {

    ms =((Math.pow(.95,level))*(1/.95));

    }

    setText("score", "Score: "+score);

    onEvent("start", "click", function( ) {

    start();

    //hideElement("start");

    });

    //i is used to change the pancake image every time one falls

    var i =0;

    function start() {

    ms=(ms*.9);

    showElement("pancake");

    setImageURL("pancake", pancakeimages[i] );

    i+=1;

    if (i>pancakeimages.length-1) {

    i=0;

    }

    x=randomNumber(0,320-75 );

    y=-100;

    setPosition("pancake", x, y, 100,100);

    fall();

    }

    //code responsible for the image "falling"

    function fall() {

    timedLoop(2, function() {

    setPosition("pancake", x, y, 100, 100);

    y=y+1;

    if (y>550) {

    stopTimedLoop();

    scoreupdate(-5);

    start();

    }

    if ((Math.abs(y+getProperty("pancake", "height")-ypan-150)<15)&&((Math.abs(x-xpan))<25)) {

    stopTimedLoop();

    hideElement("pancake");

    scoreupdate(5);

    p++;

    if (p==(5+level-1)) {

    newlevel();

    }

    start();

    }

    });

    }

    //updates scores and stats on screen

    var timer=1000;

    function scoreupdate(scorechange) {

    score=score+scorechange;

    setText("score", "Score: "+score);

    setText("scorepositive", "Score + "+scorechange + " "+score);

    setText("scorenegative", "Score "+scorechange +" "+score);

    if (scorechange>0) {

    timer=1000;

    setTimeout(function() {

    flash("scorepositive");

    timer=timer*0.75;

    setTimeout(function() {

    flash("scorepositive");

    timer=timer*0.75;

    setTimeout(function() {

    flash("scorepositive");

    }, timer);

    }, timer);

    }, 0);

    }

    else if (scorechange<0) {

    setTimeout(function() {

    flash("scorenegative");

    timer=timer*0.75;

    setTimeout(function() {

    flash("scorenegative");

    timer=timer*0.75;

    setTimeout(function() {

    flash("scorenegative");

    }, timer);

    }, timer);

    }, 0);

    }

    }

    function flash(id) {

    setTimeout(function() {

    showElement(id);

    setTimeout(function() {

    hideElement(id);

    }, timer*0.5);

    }, 0);

    }

    function newlevel() {

    p=0;

    level++;

    setText("level", "Level: "+level);

    changecolor();

    findms();

    start();

    }

    //begin written by partner1 - moves the pan on the bottom of the screen

    onEvent("screen1", "keydown", function(event) {

    xpan=getXPosition("pan");

    ypan=getYPosition("pan");

    if (event.key=="Right") {

    xpan=xpan+5;

    if (xpan>250) {

    xpan=249;

    }

    }

    if (event.key=="Left"){

    xpan=xpan-5;

    if (xpan<-80) {

    xpan=-79;

    }

    }

    if (event.key=="Down"){

    ypan=ypan+5;

    if (ypan>340){

    ypan=339;

    }

    }

    if(event.key=="Up"){

    ypan=ypan-5;

    if (ypan<280){

    ypan=279;

    }

    }

    setPosition("pan",xpan,ypan);

    });

    //ends written by partner 1

    submitted by /u/CatboatThemHolyJew
    [link] [comments]

    Introduction to WebScraping with Python, Beautiful Soup and Requests

    Posted: 21 Mar 2019 04:37 PM PDT

    Hey guys I made a video on how to do some simple webscraping with python and I thought it might be relevant here.

    The tutorial uses BeautifulSoup and requests for a very simple but I think practical example. Hopefully if you watch through the video, afterwards you may have an idea or two on how to use this for your purposes.

    Feel free to comment if you have any questions!

    https://www.youtube.com/watch?v=iECY6Z0-w54&t=1s

    submitted by /u/straightcode10
    [link] [comments]

    Do you guys know of any audio only resources to help a person learn the concepts of programming (just to help me in my car as I drive around)

    Posted: 21 Mar 2019 09:29 AM PDT

    First off I'm well aware it's nearly impossible to learn how to program without visual help or programming itself but I'm doing those things already. This would be in addition to help me learn and internalize everything faster.

    I have a job where I drive around a lot. I'm in my car probably 30 hours a week and I would really like to have something to listen to that can kind of help me out as well. Like I said I will be doing these things IRL also so if I can listen to audio talking about the things and it will help remind me of when I was doing that and kind of reinforce that memory.

    Also I'm okay with it being on Youtube in video form as long as I don't have to look at the screen lol like I can listen to a TED video or something in my car even though it's a video I don't have to watch it.

    submitted by /u/ManInBlack829
    [link] [comments]

    How to finish a project?

    Posted: 21 Mar 2019 10:39 PM PDT

    I'm finishing my junior year of college and I have a few small side projects. Nothing major that I feel like could really set me apart. Whenever I have an idea for a bigger project, I always seem to get a nice start on the project, and then mid way through I seem think "oh this is a better idea!" and I switch my focus to a different project.

    Any tips on how to stick with a project and actually finish them??

    submitted by /u/johntc121
    [link] [comments]

    At home mom failing at becoming a software developer

    Posted: 21 Mar 2019 08:15 PM PDT

    Hi I wanted to come here for help. I am looking to get a remote software engineer job because I am a stay at home mom. I began learning but my motivation just completely waned. I learned HTML, CSS, and js to a upper-beginner(?) to lower intermediate level. Now I'm trying to tackle reactJS so that I can start building a project in react.

    That being said...I have 0 motivation. I mean, my husband brings the basic necessities so you can say there's a lack of urgency. Plus... I don't really NEED a job but it would help me so much if I did. For one thing I'd move up from an at poverty family situation to some place better.

    How do I feel? I feel extremely guilty the whole time I'm not working on realizing my dream to become a software engineer I feel bad that my laziness got the best of me Idk what to do....

    Maybe this is just a rant ...sigh just help with whatever words you can give

    I'm going the self taught route btw

    submitted by /u/YasminAdams
    [link] [comments]

    How do programming languages interact with each other?

    Posted: 21 Mar 2019 06:23 AM PDT

    Hi friends! (Sorry, mobile user) Second year undergraduate CS student here. Something I've always wondered is how programming languages work together to make one program. For example, when people use different languages for a front end and back end, or how Spotify (I think) used multiple languages like C++ and Python to be created. I haven't taken an extensive software engineering class yet, and I've always been curious. Thanks!

    submitted by /u/akathepuertorican
    [link] [comments]

    Programming games?

    Posted: 21 Mar 2019 09:47 PM PDT

    Just saw (adventure land - the code MMORPG) on steam.

    I'm curious if you actually learn or practice real coding with games like this?

    Is it any good? Is there better?

    submitted by /u/BigBeautifulEyes
    [link] [comments]

    Help with Python code on Udacity CS101 Course

    Posted: 21 Mar 2019 07:04 PM PDT

    Hi everyone,

    I'm working through the Unit 2 problem set and keep getting the error "program does not terminate" when I try to submit. Unfortunately the pop up that appears doesn't tell me what inputs are causing my program to loop forever. Here's the problem and my code:

    • Define a procedure, find_last, that takes as input two strings, a search string and a target string, and returns the last position in the search string where the target string appears, or -1 if there are no occurrences. Example: find_last('aaaa', 'a') returns 3. Make sure your procedure has a return statement.

      def find_last(search_string, target_string): s = 0 if search_string.find(target_string) == -1: return -1 else: while True: x = search_string.find(target_string, s) s = s + 1 if x + len(target_string) == len(search_string): break return x 

    The test cases that Udacity provided me all work, which are shown below: #print find_last('aaaa', 'a') #>>> 3

    #print find_last('aaaaa', 'aa') #>>> 3 #print find_last('aaaa', 'b') #>>> -1 #print find_last("111111111", "1") #>>> 8 #print find_last("222222222", "") #>>> 9 #print find_last("", "3") #>>> -1 #print find_last("", "") #>>> 0 
    submitted by /u/Hayato13
    [link] [comments]

    Help with pointers in C

    Posted: 21 Mar 2019 11:12 PM PDT

    Can anyone explain why in the following code on the second iteration of the loop b and a are the same address? I assume that assigning b to the (old) a would mean *b would be 0, but apparently both a and b point to the same object. Thanks.

    void lifetime(int n) { unsigned* a = 0; unsigned* b; unsigned j = 0; while (j < n) { if (a) { printf("%d: ", j); printf("a = %u ", *a); if (b) printf("b = %u", *b); if (a == b) printf("\na and b are the same"); printf("\n---------------\n"); } b = a; a = &(unsigned){ j, }; j += 1; } } 

    output, with n = 3:

    1: a = 0 --------------- 2: a = 1 b = 1 a and b are the same --------------- 
    submitted by /u/clausewitzs_legacy
    [link] [comments]

    How do you take notes while working on a project/task

    Posted: 21 Mar 2019 10:53 PM PDT

    Title says it much. Personally I create an .md file in vscode for each task I work on, write my thoughts, what I need to do, code snippets. There's no syntax highlighting because it shows you the "raw" version or the file. I prefer it anyway because I don't to separate code and notes. Paper for quick schemes and similar.

    You?

    submitted by /u/edivadd
    [link] [comments]

    Building a portfolio

    Posted: 21 Mar 2019 04:41 PM PDT

    Hello all!

    I am sort of new to programming and really haven't coded anything unique since MySpace was around... I know pretty much everything about html/css from using MySpace and Neopets. Honestly, this is how I got my love for it. I'm using free code camp to get into the swing of things and learn how to code using java. Where should I store my portfolio? I know github is commonly used but will this show samples of my code? Also, are there jobs you can get while learning?

    submitted by /u/hoophooper
    [link] [comments]

    How do i incorporate python scripts into HTML?

    Posted: 21 Mar 2019 08:14 PM PDT

    I'm using the Spotify web api as an introduction to using an api and reading documentation, and right now I'm restricted to entering inputs via the console, which is fine, but since I'm learning HTML this year in college, I thought it'd be easier to make a local webpage that can take the inputs and display results. I think I have a good handle on how inputs and sending the information somewhere else to be processed works, but I have no clue what the python should look like to actually accept the information, or how to return something to the webpage to be displayed.

    submitted by /u/Skullrider1387
    [link] [comments]

    I'm a 15 year old and want to learn Java

    Posted: 21 Mar 2019 09:59 AM PDT

    As the title says, I'm 15 and want to learn a new programming language, I already know python and want to know where to go to learn Java

    submitted by /u/d_o_g18
    [link] [comments]

    I'm looking for some good HTML&CSS tutorials (no videos please)

    Posted: 21 Mar 2019 07:58 PM PDT

    I know, I know... HTML and CSS is not programming. But this is pretty programming related and so I thought it's okay to ask in this subreddit. Since I'm a little bit bored in my internship I want to learn HTML and CSS. I've already learned a little bit JavaScript and would like to get a little bit deeper in the formatting stuff and let things better looking.

    submitted by /u/nille_peter
    [link] [comments]

    Using Github as a backend database server?

    Posted: 21 Mar 2019 10:40 PM PDT

    So, I have an event conference coming up in few months. I just made a github io site that is free. I want to host an event registration form online where people can fill out the necessary information fields, like name, age, etc.

    once they filled out the form and submit it. How can I retrieve that information so I can make name tags?

    Can i do that on github io site and use github as a database for that?

    Help me out? I appreciated it. Thanks!

    Edit: i am a complete noob so this is my first forray into understanding database and backend stuff. It's scary.

    submitted by /u/double07_
    [link] [comments]

    Beginner's PHP Tutorial

    Posted: 21 Mar 2019 10:12 PM PDT

    Hello Everyone,

    I created a tutorial for beginners who are starting learning PHP. This tutorial has plenty of examples and most of them are well described.

    Also, I use appropriate images to easily give the idea to learners and to make it easy understand.

    Here's the link of the tutorial.

    https://developer.hyvor.com/tutorials/php/introduction

    Check it out and let me know your ideas. Thank you.

    submitted by /u/SupunKavinda
    [link] [comments]

    What I learned from making a Chrome extension and the code review post I made

    Posted: 21 Mar 2019 11:19 AM PDT

    Hello again :). I'm Jared, the guy from this code review post a while back, about the Google Chrome extension Capture. Well, I finally got the dang thing published! It's available here if you're really curious, though the point of this post isn't a self promotion (I hope it doesn't come off that way). Rather, I wanted to talk about some overarching lessons I learned through this whole process, and specifically what I learned from all the great feedback on the code review post. My hope is that may be helpful to others? At the least, you should read u/VolitiveGibbon's second reply on that thread. I doubt many people saw it since it was made well after the post left the front page. However, I'd say it was equally as helpful and insightful, if not more, than first one they made! I highly recommend giving it a look; it may save you many, many programming hours in the future. Seriously, it's half the reason I'm making this post -- just give it a look. It's about the benefits of wrappers.

    Just to back up for one second for anyone totally lost as to what I'm talking about: Capture is a Chrome extension I made. It lets you save tabs away, along with a note, such that you can easily open the website associated with your note. It also has a tag system. You make Chrome extensions with plain old HTML, CSS, and Javascript. I made a post a while back asking for a code review and got a lot of great feedback. I wanted to go over what I learned.

    So without further ado, here's some of the lessons I've learned throughout this process:

    1. If you ever get into asynchronous programming with Javascript, take the time to learn about the more modern techniques for handling async code: namely, Promises and the async/await keywords. It will be well worth it.

      When I first started doing async code in the extension, I stuck with the traditional callback technique. I still think this is important to understand, because it underlies Promises and async/await at the end of the day. Plus, I think it's easier to comprehend as you learn about async programming (fundamentally you are just passing a function to handle the output when your async call is done; instead of waiting around for it (i.e. "hanging") as sync code does). Further, some APIs still only support the callback technique.

      With all that said: MAN does the callback technique lead to some ugly and hard to read code! Before I rewrote with the more modern techniques, I had some terribly far nested code. I don't think you ever had to scroll horizontally, but it was getting there. Now, with async/await especially, the code is much easier to read and maintain. It's great.

      And by the way, if you are diving into asynchronous programminng, I HIGHLY reccomend reading this StackOverflow post about it. It's about Javascript, but it would be helpful for any language. I think it explains asynchronous programming very nicely. And be patient with yourself -- it's a pretty dang tricky concept to get.

    2. Refactor mercilessly.

      If you ever notice an opportunity to abstract something out, take it. Obviously don't wrap every line in a function, but you get my point. If you see a way you can improve your code, do it, even if it will take some extra time. You're future self will thank you.

      The reason I think this is so important is because large projects are hard to understand; and large projects that are sloppily written (read: structured poorly) are really hard to understand. I mean, Capture isn't even that large! It's really only two main JS files (DB.js and mainUI.js) -- but still, even it was getting tricky for me to follow, and I wrote the dang thing. Point is, if it's any project you're going to work on for an extended period of time, I think it's well worth the effort to refactor. Even if it will take a while. Plus, everyone likes to work on well written code, so you'll be much more likely to get help online / contributors. AND you'll be more likely to write good code if you already have good code; because who wants to ruin nice code?

      Speaking of refactoring and code structure... here's probably the biggest lesson I learned.

    3. Encapsulation via classes in OOP is incredibly useful.

      I'm not going to pretend to be an expert on OOP principles, but I'll do my best to convince you here. If you are anything like me, you've learned about OOP in school (probably with Java) and used it in a few school projects, but maybe never used it extensively in your own projects. You've been told about all these benefits, like maybe how encapsulation lets you change internal variable names in class and not have to change them everywhere else (Encapsulation is actually much more broad than that though, imo). And maybe you even know the syntax well for it in your favorite language. Still, I think it's hard to internalize the concepts until you apply them in one of your own projects. I mean, I too was taught about these benefits, and I still didn't apply them when I initially wrote my code! So I will try to explain why it's so useful.

      By the way, I am essentially paraphrasing u/VolitiveGibbon 's second reply that I previously mentioned. Again, you should really read it. Ok, on to the reasoning.

      When I initially wrote the code, I had references to my PouchDB database client all over the extension. This seemed fine to me at the time, and I suppose there's nothing technically wrong about it, but it's not good design. Why? Well consider some situation where PouchDB is no longer available to me; maybe it goes paid, has a non backwards compatible update, etc etc etc. Now I have to go through my entire codebase, replacing all references to PouchDB with a new database client. Even if I was so fortunate to find a DB client with the exact same interface, that would still take me at least an hour or two. And of course, it's quite unlikely that the two would have the same interface.

      BUT, imagine this! Imagine I made class, call it DB.js or whatever, and routed all my interaction with PouchDB through it. Even something as simple as calling myDB.save(doc), which then directly calls myPouchDBClient.save(doc); instead of just calling myPouchDBClient.save(doc) all over my code. Seems kinda redundant huh? Well, it's actually incredibly useful. Because again, consider the case where PouchDB is no longer available. Now, if I have been using this class all throughout my code, calling myDB.save(doc) instead of myPouchDBClient.save(doc), I only have to fix my code in one spot. That is it; once I re implement that interface, I am done. That's a HUGE benefit; I went from needing to comb through all of my code, to just needing to fix one file. And, once I do refactor, I can be much more confident that my extension will work properly! The upshot? Even a paper thin wrapper class can be useful, because it improves future maintainability. You could also say it reduces the impact of change and limits a heavy dependency (like a DB client).

      But wait right there! The benefits of OOP go even further than just improving future maintainability. BY encapsulating all my database access in the DB.class (I.e., the entire extension's state is managed by the DB class; the only way to change the stored state is via that class), my code is much times easier to think about. How so? Well I mentioned above that perhaps the class is just a thin wrapper for calls to a database client -- and that's true for some of the methods in my DB.js class (namely getSnip(), allSnips(), getTags(), and allTags() -- those methods basically just call .get() and .allDocs() on PDB). And again, thin wrappers are still very useful! But of course, you can actually do stuff in a method! There's no need for it to be thin.

      So in the class, I also have three other methods: saveSnip(), updateSnipText(), and deleteSnip(). All three of these methods keep two databases (dbForSnips and dbForTags) in sync as they work. This is needed because, for instance, if a new snip is saved, both dbForSnips and dbForTags need to be updated. So they abstract out some very useful functionality for me, and provide to me a nice, simplified interface. Further, this interface makes sense in the context of the code; instead of saying .save(), I call .saveSnip(), which is semantically much clearer. They make my code much easier to reason about, because I don't have to think about the the nitty gritty of the maintaining the DB state in the majority of my extension. I just call saveSnip() or deleteSnip() and I'm off to the races. It's great!

      So by routing all my DB access through this DB class (i.e., encapsulating it all), my code is much easier to think about. This is the broader applicability of encapsulation. For instance: say one day I want to make some functionality to rename a tag. What do I do? Well, simply add a method like renameTag() to my DB class, that properly updates both the dbForSnips and dbForTags. That's all the database stuff done, because the database stuff is completely separate from the UI. Then, link that up to some button in my mainUI, and we are done. That's it -- that's all you gotta do, because you used encapsulation to completely bundle up all your DB access into one unit.

      I hope I've made my point clear, and paraphrased u/VolitiveGibbon well (in hindsight, it's more of an elaboration; their explanation is shorter, lol). Here's the overall upshot: Encapsulation via classes in OOP is incredibly useful, because it massively improves future maintainability, and lets you create simplified interfaces that make your code much easier to reason about. In my case, I use a class to completely encapsulate my DB access, abstracting away the nitty gritty of keeping two databases in sync. This lets me easily think about all my database access via one interface, and one unit -- plus it greatly reduces the extension's dependency on PouchDB. So basically, if you notice yourself doing a lot of work on some data in your code -- abstract it out into a class, encapsulate it up, make that simplified interface, and reap the rewards.

    And to wrap up, here's some of the smaller ones that I don't think need bolding: Functions should do one thing and one thing only, and they should do it well. Ideally, don't mutate your arguments either -- just return new objects. Also, try to use const wherever you can in Javascript; it makes your code easier to think about, in general. Lastly, never underestimate how long a project will take.

    I am of course still learning too, so I am open to any suggestions if you have them :) (for the code or the extension or the UI, whatever). I'd say Capture is only in Alpha right now, so it still has plenty to go. Either way, I hope the post was helpful in some way. I've at least learned a lot by all this.

    Have a good one!

    TL;DR: Made a Chrome extension called Capture. Made a code review post for it and got a lot of good feedback. Main things I learned are a) you should really use the modern techniques for async JS code, b) refactor mercilessly, and c) encapsulation via classes in OOP is incredibly useful, because it improves your future attainability, and lets you create simplified interfaces that make your code much easier to reason about.

    submitted by /u/nameEqualsJared
    [link] [comments]

    [Java] Why can I assign a boolean in this IF statement?

    Posted: 21 Mar 2019 09:39 PM PDT

    This compiles

    boolean M = false;

    if (M = true) {

    System.out.println("TRUE!");

    } else {

    System.out.println("FALSE");

    }

    This does not compile

    int X = 20, Y = 40;

    if (X = Y) {

    System.out.println ("Numbers are the same !");

    }

    Why?

    submitted by /u/total_sleezeball
    [link] [comments]

    Programming for drones

    Posted: 21 Mar 2019 09:37 PM PDT

    New to programming so which language is most suited for the programming of drones? Additionally where do i start the programming and ensure it results in a feasible working drone?

    submitted by /u/Acespartan33
    [link] [comments]

    [Code Review] Cows & Bulls - Implemented using Python

    Posted: 21 Mar 2019 09:33 PM PDT

    First code post!

    I have been thinking of making this "game" for a while now - and decided to get down to it - took me under 10 hours to get here. Proving to me I don't actually suck too badly at programming.

    How ever I feel very uncertain about the quality of the code & how I'm going about it. I did check-out the style guide, and think that my code is quite consistent - but would love to get some review.

    Review areas:

    • How's my commenting? How can I improve?
    • How's the structure of the code? Am I using too many functions? Should I be using more functions?
    • How much of time should i be spending designing tests/health checks for each of the functions?

    Here's my repository : https://github.com/robothormones/cowsnbulls

    Here's the read-me for the game: https://github.com/robothormones/cowsnbulls/blob/master/README.md

    To play:

    Run : https://github.com/robothormones/cowsnbulls/blob/master/begin_game.py

    Thanks & Looking forward to your inputs.

    submitted by /u/anoneesh
    [link] [comments]

    Python simple question

    Posted: 21 Mar 2019 05:25 PM PDT

    I am making a simple calculator in Python but I am having some trouble understanding these basic functions, could you help me clarify my understanding?

    def add (x, y):

    return x + y

    This function is defining the 'add' variable to produce a 'variable + variable' function when we call it. So from a students perspective, the x and y are just place holders for the two choices that a user would input?

    print (num1, "+", num2, "=", add(num1, num2))

    This one is the tricky one, for me. What I do not understand, is:

    1. Why do we have to put quotation marks around an operator? from a logical standpoint, I thought quotation marks would convert every character in between into a string?
    2. I don't understand why we have to write the first half of the operation when the function is in the second half. Why can't we just use: print(add(num1, num2)) and be done with it?

    Thanks guys would appreciate some help with this.


    [link] [comments]

    No comments:

    Post a Comment