• Breaking News

    Wednesday, April 17, 2019

    "Automate the Boring Stuff" author refactoring beginner's code on a live stream Wed 4/17 at 7pm pacific learn programming

    "Automate the Boring Stuff" author refactoring beginner's code on a live stream Wed 4/17 at 7pm pacific learn programming


    "Automate the Boring Stuff" author refactoring beginner's code on a live stream Wed 4/17 at 7pm pacific

    Posted: 16 Apr 2019 12:53 PM PDT

    Hello, Reddit! I'll be going over a short Python game written by a beginner and showing how I'd refactor the code so that it does the same thing but with shorter, more readable code.

    I'll be streaming tomorrow evening, Wednesday 4/17/2019 at 7pm Pacific at https://www.twitch.tv/alsweigart/ and answering questions folks post to the chat room. If you can't make it, this stream will be recorded and later posted to YouTube.

    Some of the themes I'll cover are:

    • How to avoid "Choose Your Own Adventure" style code, which depends on flow control instead of data structures.
    • How to remove duplicate code (and why you'd want to).
    • When you should replace multiple variables with a list or dictionary.
    • How you can save yourself effort by using the Python standard library.

    If you have programs you'd like to see me refactor, feel free to PM me or post as a comment here your pastebin.com link. To make sure the audience can follow along and it's easy to stream, I'd like to ask that they:

    • Generally be between 10 and 300 lines of code in a single file.
    • Only use the Python standard library and not require additional modules.
    • Not require additional files, like files that need to be on your computer, or account info or special permissions or environment setups.

    See you then!

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

    Lets talk about some simple Python projects that are ideal for beginners

    Posted: 16 Apr 2019 04:17 AM PDT

    Hi People,

    So I am getting a little familiar with python. I've completed 3 weeks of the MIT course that you can take for free. I've run some code like opening a tab in my browser and like a simple quiz that you can open, take and then close when you're done.

    Now, I'm just getting impatient!! Like I can't seem to find help with step by step for making a simple USEFUL program. Anyone willing to lay out/talk about some real life examples of some simple modules/programs/source code that might be interesting to try out or look into.

    ALL I HAVE IS PYTHON 3.7.2 ON A WINDOWS COMPUTER USING PYTHONS IDE

    Questions:

    1. IDE's you use and what makes it easy (I'm a neat-freak and love keeping things really organized and noted)
    2. What are some short programs I should try in relation to monkeying around with data that would be used in a work environment?
    3. Have you come across any good subreddits for some of the questions I'm asking?
    4. Show me some modules/code for cool things I should try/research into!!

    Anything helps :) Just a curious Millennial that has no life outside of work. I have nothing to do after work so I devoting a lot of time into picking up a useful skill. I choose python for a start and hope it's just the beginning.

    No one I know wants to better themselves this way so I've just isolated myself. I keep learning and trying new things but I really want computer programming to stick. Just having a rough start. Hit me up or comment if you have some insight.

    submitted by /u/Smart-Unknown
    [link] [comments]

    Let's Master Python (Live 2 hour boot camp this weekend)

    Posted: 16 Apr 2019 08:55 AM PDT

    Hi folks, I am a self-taught programmer and know how lonely and frustrating learning programming can be. Last year, I shared about the free, live python/data analysis/web development etc. online classes I ran with this community. I was thrilled with the student responses. Many students shared that the live classes gave them the discipline to learn new skills. It was an inspiring community as well, helping each other clarify doubts and offering encouragement.

    After a brief hiatus, I have decided to continue offering these classes for the community. This weekend (both Saturday and Sunday), I will be offering a 2-hour Intro to Python Bootcamp. In the class, you will learn key concepts in python like variables, functions, classes, and build simple programs.

    Who should sign up for? Complete beginners who are new to Python. Those who want to refresh knowledge of Python will also find it helpful.

    Want to know more? Take a look here:

    https://docs.google.com/forms/d/e/1FAIpQLSeUcHHhmNkPRkKNpHsJO1CYTtr8n9PXWQN5tjped2__ioO2BA/viewform?usp=sf_link

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

    Cloud Developing Career

    Posted: 16 Apr 2019 10:33 PM PDT

    What should be my approach to programming languages, if I want to become a Cloud Developer ? I have done all basic concepts in C++ and Python

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

    Is making games a good way to reinforce programming skills?

    Posted: 16 Apr 2019 09:51 PM PDT

    Hi all,

    I read somewhere a while ago that for making side projects, a good route to go is to start making games since it really hones in on basic programming concepts and good design skills.

    Do you agree with this sentiment or is there another route in which programmers should go on?

    As for me, I really want to make games but I am really really confused on where to start. I have decent experience with Java and C++ with syntax and moderate experience in software designing but I really don't know how to start making a game. I've tried to look at the tutorials of the various libraries on YouTube but I don't know how to apply those concepts to an actual original game that I want to make, no matter how simple.

    Is there a good video series, course, or book you guys can recommend to me? I really want to get some side projects established.

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

    I hate ORMs. Is raw SQL in my webapps / REST APIs in production okay?

    Posted: 16 Apr 2019 01:18 PM PDT

    Obviously using prepared statements and other SQL injection protections. For reference, I'm building apps in NodeJS using Sequelize + Express. As the DBA + App Dev on my team, ORMs are just a hurdle to me, since I know the models inside and out (because I built them, see the part where I said I was the DBA).

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

    My program gives me a return error and I can't figure out why its doing so?

    Posted: 16 Apr 2019 05:25 PM PDT

    We weren't allowed to use || or && because my teacher says that it's inefficient and there are better ways to solve the problem.

    I asked this question yesterday and was told it was because I hadn't programmed a way to get a return statement if all three numbers were equal I did that and it still won't go.

    package problem45_greatest; public class Problem45_Greatest { public static void main(String[] args) { System.out.println("Greatest " + greatest(5,6,7)); } public static int greatest(int num1, int num2, int num3){ if(num1 > num2) if(num1 > num3) return num1; if(num2>num1) if(num2>num3) return num2; if(num3>num2) if(num3>num1) return num3; if(num1==num2) if(num1>num3) return num1; if(num2==num3) if(num2>num1) return num2; if(num3==num1) if (num3>num2) return num3; if(num1==num2) if(num2==num3) return num1; if(num1==num3) if(num3==num2) return num1; if(num3==num2) if(num2==num1) return num1; } } 
    submitted by /u/spikelived321
    [link] [comments]

    Copywriting or Software Engineering?

    Posted: 16 Apr 2019 08:32 PM PDT

    I asked this in the copywriting subreddit, but I wanted to ask the same question here in the learnprogramming subreddit.

    I am at deciding on a career between Copywriting or Software Engineering. I love writing and I bought an online copywriting course a while back that I am just now getting back into it. However, I also love tech and have been learning how to code the past few months, as well.

    I realize that taking up either opportunity seems rewarding and would both bring with them a potentially high income. In fact, I would like to master both at some point, but for now, I would like to simply make a sound decision on just one of them.

    Which one do you think that I should master first, and why?

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

    Difficulty with recursion feeling abstract

    Posted: 16 Apr 2019 11:54 PM PDT

    When I look at solutions of recursion problems, I can understand them. But when it comes to coming up to those solutions I am majorly struggling. Is there any notable resources I should be using? The language I am learning it in is ruby if that helps.

    An example of a problem that is challenging me is called first_even_numbers(n)

    Solution code is

    def first_even_numbers(n)

    return 2 if n == 1

    2 * n + first_even_numbers_sum(n-1)

    end

    So logically the base case is 1 and the meat of the problem is 2*n + (n-1) repeated until number equals 1? I am struggling to see how that is only giving me the even number sums. Hope I've explained that well enough

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

    Tkinter help

    Posted: 16 Apr 2019 11:50 PM PDT

    Guys, I am using tkinter on python to create a simple game. It's just a card game and I want the whole program to run again when I press a button. How would I do that?

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

    My friend needs help with his LC3 Coding Project

    Posted: 16 Apr 2019 11:44 PM PDT

    He's currently taking up Computer Science in College and has a problem with his LC3 code.

    Project:

    His task is to ask the user to enter a text. Assume that the text is shorter than 99 characters, the user only types upper-case, lower-case characters, and spacebar. The program should perform a number of simple analysis such as counting how many characters the user has typed, how many of them are uppercase letters, lowercase letters and spaces.

    His program currently projects the following lines:

    The text you have typed is: Hello World Number: A ---- Halting the processor ---- Students Name, ID number: XXXXX, 123456 Please enter a text: Hello The text you have typed is: Hello Number: 9 ---- Halting the processor ---- Students Name, ID Number: XXXXX, 123456 Please enter a text: Hello World 123 The text you have typed is: Hello World 123 Number: ? ---- Halting the processor ---- 

    This is his code currently:

    Lea r0, StudentString ;load the address of StudentString to Register 0 puts ;print it out Lea r0, PromptString ;load address of EnterString to Register 0 puts lea r2, SaveString ;load address of SaveString to register 2 LOOP ;label loop which is used to make the program counter to go back getc ;get character add r1, r0, -10 ;subtract 10 brz OUTSIDE str r0, r2, #0 ;store add r2, r2, #1 ;acts as a counter for storage add r3, r3, #1 ;counter out ;print out what is in R0 brnzp LOOP ;go back to the Label LOOP in all cases OUTSIDE ;needed to move out of the loop Lea r0, InputString ;print out the contents in InputString puts Lea r0, SaveString ;print out the contents in SaveString puts Lea r0, NumberCharacter puts ld r0, CharacterCounter add r0, r0, r3 out Halt ;print out halt and stop the program StudentString .stringz "Students Name, ID number: XXXXXXXXX, 123456789" PromptString .stringz "\nPlease enter a text: " InputString .stringz "\nThe text you have typed is: " NumberCharacter .stringz "\nNumber: " SaveString .blkw 100 CharacterCounter .fill x30 .end 
    submitted by /u/Voltes_5
    [link] [comments]

    Android system application to turn on HotSpot Tethering Programmatically in Oreo?

    Posted: 16 Apr 2019 11:27 PM PDT

    Hi Guys,

    wifi HotSpot application as system apk in AOSP.

    Application will perform following steps:

    1. SSID and presharedKey will be set for HotSpot from application - working.
    2. Turn ON HotSpot tethering from application - Failed.

    Methods to turn ON HotSpot from application:

    1. Tried using setWifiApEnabled method but deprecated in Oreo.
    2. systemAPI ConnectivityManager#startTethering available - How to use?

    Can anybody share some snippet allowing use of ConnectivityManager::startTethering?

    I was unable to provide OnStartTetheringCallback parameter.

    Thanks for your help in advance.

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

    Show Visualiser (com.chibde.visualizer.LineBarVisualizer) always in action even if switching activities

    Posted: 16 Apr 2019 11:21 PM PDT

    So i am using com.chibde.visualizer.LineBarVisualizer for some visual effect to songs playing in MediaPlayer. But the thing is when i change activity and come back to the activity where song was playing with visualiser the visualiser is gone. I am aware that LineBarVisualizer uses audiosessionid fr effect to show up. I am even trying to save the audiosessionid in savedinstance and restoring on restoresavedinstance but it responds only to orientation change, not to activity change.

    https://stackoverflow.com/questions/55715093/show-visualiser-com-chibde-visualizer-linebarvisualizer-always-in-action-even

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

    [Python] Can you call a function vs a second function if a variable is met?

    Posted: 16 Apr 2019 11:21 PM PDT

    New to programming here and learning Python.

    As an assignment i am working on a text based game and i've created two functions, one that will ask simple addition and subtraction questions, another that will ask multiplication and division questions, I am wondering if it is possible to have the game loop run with one function being called based on a skill level being entered and have the game call that function throughout the entire game without having to have two branches of the game, one for skill one and one for skill two? I know i could do it in two branches using something like:

    skill = int(input("Skill level 1 or 2?")) while skill == 1: branch1() while skill == 2: branch2() else: print("Invalid input.") skill = int(input("Skill level 1 or 2?)) 

    But that would require me to copy and paste the entire game loop in twice which is messy. Am i missing a cleaner way of doing this?

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

    Is programming for me? A few have already told me, directly, that programming isn't for me.

    Posted: 16 Apr 2019 11:14 PM PDT

    Title says it all. I'll try to say information about this piece by piece because the people who said this might do something about it. I'm kinda having a hard time learning Java and C++. Not at the same time. Lol. But, yeah. I, too, think it's not for me because I'm having a hard time. Some people are already probably making fun of me because I can't even finish the god damn 34th exercise in MOOC. Should I quit? Should I learn another language instead?

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

    ELI5 - How do java interfaces work?

    Posted: 16 Apr 2019 11:09 PM PDT

    Hi everyone,

    Asking for a work friend needing help and they don't use Reddit. Any links or resources will be useful.

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

    Where to learn specific Machine Learning implementation?

    Posted: 16 Apr 2019 04:58 PM PDT

    Hi all,

    I'm working on a senior design project that I think could be improved by machine learning, but I'm not sure where to learn exactly how I could do that. I'm basically creating a formula to approximate something, and I want to use ML to improve that existing formula.

    More specifically, I'm making use of some ideas presented in the book "The Intelligent Investor" to create a formula that will approximate the future value of a stock. At the end of the research it should be a fairly straight forward, take in some variables, weight them differently, do operations and spit out an approximation. I would like to be able to then take this existing formula and improve it with machine learning.

    Is that something one can use ML to do? Everything I've seen is more related to using strictly machine learning from the ground up to accomplish calculations, instead of improving an existing method.

    I've never worked with any ML, so forgive me if this is a dumb question! I've taken a robot vision course so I know the gist of how to neural networks work mathematically, but not actually in practice. Never worked with an actual library like Pandas or anything.

    And also a small notice, I don't expect to see awesome returns or create a magic investment app, this is more a fun proof of concept of some ideas presented in an investment book.

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

    Cyberstart Assess U.S

    Posted: 16 Apr 2019 10:29 PM PDT

    Cyberstart Assess challenges?? I would love to collaborate I'm stuck on challenge 12 and 14..

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

    BeautifulSoup4 noob here Parsing HTML Data

    Posted: 16 Apr 2019 06:41 PM PDT

    Aloha! Thanks for taking the time to read this.

    So here is my code:

    from bs4 import BeautifulSoup
    import requests

    url = ('https://www.pcworld.co.uk/gbuk/search-keywords/xx\_xx\_xx\_xx\_xx/rtx%2B2060/xx-criteria.html')
    url_html = requests.get(url).text
    soup = BeautifulSoup(url_html, 'html.parser') # bs4 parses the information from the url
    containers = soup.find_all("article", class_="product result-prd clearfix") # this separates the items from the rest of the website
    for container in containers:
    url_product = container.findAll('a', href=True) # finds all containers which has the a tag and a href tag too
    url_prod = url_product[0]
    print(url_prod)

    This is an example of the ouput:

    <a href="[https://www.pcworld.co.uk/gbuk/computing-accessories/components-and-upgrades/graphics-cards/gigabyte-geforce-rtx-2060-6-gb-oc-graphics-card-10189802-pdt.html](https://www.pcworld.co.uk/gbuk/computing-accessories/components-and-upgrades/graphics-cards/gigabyte-geforce-rtx-2060-6-gb-oc-graphics-card-10189802-pdt.html)">

    <span data-product="brand">GIGABYTE</span>

    <span data-product="name">GeForce RTX 2060 6 GB OC Graphics Card</span>

    </a>

    What I want is just that link: "https://www.pcworld.co.uk/gbuk/computing-accessories/components-and-upgrades/graphics-cards/gigabyte-geforce-rtx-2060-6-gb-oc-graphics-card-10189802-pdt.html"

    I have tried: url_product = container.findAll('header', {"class": "productTitle"})['href']

    However, gives me the error:

    url_product = container.findAll('header', {"class": "productTitle"})['href'] # finds all containers which has the a tag and a href tag too

    TypeError: list indices must be integers or slices, not str

    Which I also have no idea to solve, I tried using .split() but gives me the same error.

    Any ideas how to solve this?

    Thanks!

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

    [java] “Which of the following statements do you use to jump to the end of a loop from within the loop?” This is referring to a break, right?

    Posted: 16 Apr 2019 01:36 PM PDT

    This was a question on a midterm exam. IIRC the choices were continue, break, release, and something else. (Is release even a thing?)

    I answered break, and got the question wrong. I emailed my teacher about it and he just referred me to a page in the textbook, which I looked at. It says:

    To jump to the end of the current loop, you can use the break statement

    To skip the rest of the statements in the current loop and jump to the top of the current loop, you can use the continue statement.

    So the answer is break, right? That's what I told him: I said "On my second attempt I got a question: Which of the following statements do you use to jump to the end of a loop from within the loop? I selected break and got the question wrong. What would be the correct answer?"

    And then he sent me the page numbers, and I replied back "So the answer is break? The results told me I was wrong when I selected break"

    And then he sent me a picture from the textbook showing the continue loop: https://imgur.com/a/LI8aFaw

    And I'm just sitting here thinking what? In what world is this description referring to a continue loop? Not to mention that earlier in the exam I had a question asking "Which of the following is used to skip the rest of the statements and jump to the top of the loop?" Which is obviously a continue statement. Also when googling this question I got wrong, it provides me a quizlet link with the question and the answer being break.

    This is so petty and a simple question but I don't want to lose points for things I got right.

    Am I really dumb, or is my instructor?

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

    Python 3.x Selenium alternative

    Posted: 16 Apr 2019 09:55 PM PDT

    Hello guys!

    Currently, I am working with selenium to automate some things with browsers like UI-Testing (using "Splinter").

    There are hundreds of pages which explains how to do things with selenium.

    But my question is, are there any other frameworks to automate browser interactions (clicking Buttons, fill forms, check if elements are existing, etc.)?

    My mind is playing with the idea to use e.g. the chromedriver directly and building a own framework around it, or using WebDriver JSON Wire Protocol itself.

    Any suggestions?

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

    Concise & Slow vs Verbose & Fast

    Posted: 16 Apr 2019 09:55 PM PDT

    So I have been practicing brain teasers on sites like hacker rank and code wars. One thing I noticed is that often the top voted solutions place a disproportionate amount of emphasis on how short the code is. This is especially obvious for python codes since the language has so much syntactic sugar you can often make a one liner for something complicated. However I also found instances where the top solutions do a ton of unnecessary work because of the authors' insistence on writing short code as opposed to longer but faster code. Not to mention one liners are nigh unreadable sometimes, where figuring out why exactly they work can be harder than figuring out the problems themselves.

    Am I crazy in thinking that code of this nature is actually pretty bad and unproductive?

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

    Automating the “boring stuff”

    Posted: 16 Apr 2019 09:53 PM PDT

    I saw a post explaining a process to "automate the boring stuff". If we're being honest, the "boring stuff" could mean most of the code.

    If you can automate the "boring stuff" what does this mean for the future of programming? Specifically job security, because it's automation we're talking about here.

    Please don't get mad if this sounds stupid. I'm very new to code and looking for answers.

    EDIT: I don't think code is boring. That's why I put "boring stuff" in quotes. I'm just trying to drive the point that most of the code could potentially be automated.

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

    No comments:

    Post a Comment