• Breaking News

    Thursday, April 29, 2021

    I Finally Solved A Real Problem With Python learn programming

    I Finally Solved A Real Problem With Python learn programming


    I Finally Solved A Real Problem With Python

    Posted: 29 Apr 2021 02:38 PM PDT

    I've been trying to self-teach programming for 20 years now. I never really felt like I made any progress. I'd make nifty little calculators and whatnot, but never anything meaningful.

    Well, today my Support Director let me know she'd fallen behind on the list of our customers for our infrastructure outage status page. We have over 750 customers and she hadn't done it for nearly 200 customers. So, she had a 750 person list of customers from our CRM and a 550+ list of customers on our status page. I had just finished a course on Python and told her to send me the spreadsheets.

    It took about 1.5 hours, but I did it. I made a script (16 lines) that took both sheets, put them into two independent arrays, and then did a comparative for loop. I noticed it wasn't getting all of them in a single for loop, so I created a while loop and printed the element, along with the value of i. Turned out it only needed 4 iterations of the for loop to get the job done. However, I then noticed some of the information on one spreadsheet had caps and duplicates, while the other did not. This resulted in some of the data not being de-duplicated in the script. So I used excel to lowercase and de-duplicate the data. Which then made me realize I could have done the job entirely in excel. But who cares, because I did it in python!

    Now the account reps will never know the monotonous job I saved them from. My next project will be creating an inventory UI the installation techs can use for inventory management.

    If anyone is interested in what I made:

    import pyexcel as pe from pyexcel_xlsx import save_data long = pe.get_array(file_name='sheet1.xlsx') short = pe.get_array(file_name='sheet2.xlsx') i = 0 while i < 5: for element in long: if element in short: long.remove(element) print(element) i += 1 print(i) save_data('difference-final.xlsx', long) 
    submitted by /u/Michamus
    [link] [comments]

    Python: I'm expecting this number to converge to 0.66 repeating, but it's converging to 0.5. Math is not necessarily my strong suit, so I'm not sure I'm doing wrong. Any help is appreciated!

    Posted: 29 Apr 2021 08:49 PM PDT

    import random succeeded = 0 failed = 0 for x in range(1000): num = random.randint(0, 2) if num in [0, 1]: succeeded = succeeded + 1 else: failed = failed + 1 print(failed / succeeded) 

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

    Is there anyone here who enjoys programming as much as people enjoy gaming?

    Posted: 29 Apr 2021 10:06 PM PDT

    So when you hop on your computer or whatever do you have a strong urge to just want to sit there and code all day like I would but playing a game all day? Just curious because I don't have that feeling. It's more of a side feeling right now while learning the basics of python.

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

    Is this problem a variation of another problem?

    Posted: 29 Apr 2021 10:05 PM PDT

    I have this problem that I think is related to the "rotting oranges dynamic programming problem"

    There's an outbreak COVID in a city. The city wishes to contain the virus by building walls to contain the infected. The city is built in an n by n grid. The city can construct walls separating any two adjacent grid squares. (Squares are adjacent if they share an edge, so squares that are diagonal from each other are not adjacent. An interior square is adjacent to 4 other squares.) Once the walls are constructed, the virus will spread between any two adjacent squares as long as there isn't a wall between them. It will only stop spreading once every infected square has either a wall or another infected square at each of its sides. At this point, the virus will be contained. it will cost 1 dollar to build any single wall and that the city will incur a cost of c > 0 dollars for each originally healthy square that is infected. The city already has walls surrounding it. So there is no chance of the plague infecting anything outside the city grid. Given an n by n binary matrix A, where Ai,j = 1 if the corresponding grid square is initially infected with the plague and Ai,j = 0 if the square is not infected. Give an efficient algorithm to determine which walls to erect so as to minimize the total cost and find the runtime (the number of walls build plus c times the number of originally healthy squares infected). Assume c is a small constant 

    Is that a similar problem? If not, how should I approach this?

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

    Java mutex causing "missed input" compared to busy loop for multithreaded server?

    Posted: 29 Apr 2021 11:07 PM PDT

    Hey everyone, I'm writing a Java program that interfaces with a C program on my Linux server (it's a client/server chat program). Right now, I'm implementing a blocking feature for the input to block until the user presses "Enter" before sending the input to the server. To do this, I have two choices: a busy loop, and a mutex. The mutex is obviously the best alternative, but I'm running into an issue where sometimes the input just won't send to the server at *all*. With the busy loop, though, I just unset a flag and it works fine.

    Busy loop:

    String line = ""; // Block until we receive some input. while (!this.inputField.isReady()) { } line = this.inputField.getText(); this.writefp.write(line + "\n"); this.writefp.flush(); this.inputField.setReady(false); 

    So, all I need to do in the textfield (in a keylistener) is:

    ... public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { ready = true; setText(""); } } ... 

    So, yes, this works. My mutex solution isn't so lucky:

    while (!this.inputField.isReady()) { synchronized(this.inputField.mutex) { try { this.inputField.mutex.wait(); } ... //redacted for simplicity } } 

    And the notifier:

    ... ready = true; // This is in the TextField class. synchronized(this.mutex) { this.mutex.notify(); } setText(""); ... 

    Maybe I'm misunderstanding a fundamental piece of Java's synchronization capabilities (this is much easier in C...). the mutex is just a standard Object, following online examples. Any help would be greatly appreciated.

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

    How to stylé my project

    Posted: 29 Apr 2021 11:06 PM PDT

    Hi everyone,

    I have to do a project for a friend of mine, something really interesting and kinda big. I will use react express and mongo ( maybe graph to learn it ) but I don't know what to use to style it. I used multiple times styled component and kinda like it. I recently discovered Tailwind and people tends to say it good or bad but it's better than styled component for performance.

    I wanted to use bootstrap or material but a lot of people think it's a bad habit which leads to a misunderstanding of css which is not what I want.

    Si what is your advice on this one ? Pure css ( i don't like it beacause I really like the component thinking of react and I know a some point I will have a messy css ). Sass ? Which I absolutely don't know. Styled component ? Which I really liked but know ( a few I don't k ow even 10% of its possibilities ) but makes my component a bit messy. Or tailwind which probably makes my component almost as messy but with better performance ? My objective here: continue to learn css to be good at it and have a good project maybe with a new tech.

    Thank you in advance !

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

    Would it be a good idea to take a ‘break’ from the course/tutorial I’m doing to just focus on solving problems on CodeWars?

    Posted: 29 Apr 2021 10:55 PM PDT

    Or should I continue the course and do CodeWars at the same time? I'm starting to get a little burnt out of learning and want to do more 'doing' but I also know I can push through the course if I tried

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

    How to get started with python

    Posted: 29 Apr 2021 03:41 PM PDT

    So I want to seriously get into coding. (Python). (Important!: I'm a 13 dude who doesn't have any money)I watched a video abt it and it wasn't helpful at all. So is there a way where a I can learn python for free ? I don't care if it is a video, a website or even a game. If yes can y'all also tell me a good code sculptor?

    submitted by /u/your-mama-is-gay
    [link] [comments]

    I'm 17yo will I regret rejecting 2 jobs offers ?

    Posted: 29 Apr 2021 04:12 PM PDT

    I started learning programming at 15, now I'm 17yo. 3months ago I rejected an offer at a startup because their business model sucks (they are switching to a fiverr agency and I will be the only Developer who codes the projects/ websites and get 50% of the money meanwhile the 5 co-founders sit and watch they call it doing administrative stuff but what the hell will u administer u literally have 1 kid Developer, keep in my they are all developers and have more experience than me) And just now I rejected an offer at a gambling/ casino gaming website ( my job is to create two WebGL games using unity) firstly because their business is shady and also because gambling is illegal in my country (we are both in the same country) Did I do the right thing ? I also plan to start applying to jobs or freelancing as a backend software developer this summer, the last two offers were just by having a GitHub portfolio

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

    Why is space complexity of reversing a linked list O(1)?

    Posted: 29 Apr 2021 10:08 PM PDT

    /** * Definition for singly-linked list. * function ListNode(val, next) { * this.val = (val===undefined ? 0 : val) * this.next = (next===undefined ? null : next) * } */ /** * @param {ListNode} head * @return {ListNode} */ var reverseList = function(head) { let prev = null while(head){ const next = head.next; head.next = prev; //Switch the arrow prev = head; //Move prev pointer by 1 head = next; //Move head pointer by 1 } return prev }; 

    From my understanding when we are creating an object or updating an object values the space complexity will be O(n).

    Source: https://www.youtube.com/watch?v=_F29n4Z69rE&t=83s

    But this video says the space complexity is O(1): https://youtu.be/BMfqGJTcoms?t=429

    Am I in the wrong?

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

    How do remote full time programming jobs work?

    Posted: 29 Apr 2021 12:19 PM PDT

    Hi.

    I am soon turning 18, and I have been programming all types of things (games, neural networks and websites mostly) since I was around 12. I am starting to look for a job now, probably web development (I haven't even graduated from high school yet and compared to other fields web dev seems to have the lowest entry barrier).

    My question is, most of the remote jobs I find around are full-time, and... how?

    I get normal fulltime jobs, you enter a building, and you leave 8 hours later. But what about remote jobs? Is the full-time part defined by the amount of work or something similar? And if so, based on you guys's experience , if I managed to get a job would it be possible for me to both work there (full-time remote I mean) and attend school?

    Thank you in advance :)

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

    I'm tired of being stuck and not knowing where to start

    Posted: 29 Apr 2021 09:52 PM PDT

    A little background. I graduated in 2015 with a bachelors in chemistry and was a semester away from graduating with a msters in analytical chemistry until I realized that me being in that field really relied on who I knew (no one) or if I had a PhD.

    I've been ran around with contract positions that offer no healthcare and no PTO for 4 years. I'd get paid more, but every position was short lived (contract). I basically could have a job for over a year then the next day a project is killed or they run out of money and I'm stuck burning through all of my savings until I find a job. Rinse and repeat.

    The reason my masters in chem didn't come to an end is because I dropped it to start a masters in CS. I don't think this worked well? The class used JSTOR. Which I'm not very familiar with compileriers (not sure if this is the correct word, but I've never seen it mentioned outside of that. I busted my ass in CS 1 learning JAVA and discrete mathmatics. Anyways, I'm so sick of working in a new job each year. They pay alright (way less than my peers) and current working somewith litterally no oganization (as in no SPOs and no training while stating that they have experienced memebers while my manager can't figure out troubleshooting (he's really cool but pressure can crack him and we just hired a 17 year old with the same title as me that's related to the VP).

    I really want to just branch off I need reccomendations. Like a start to job if possible (I know this is hard). I want to do either JAVA or Python. Jumping into this by yourself is a bunch of "whatever you feel like" and idk what I feel like if that make sense?

    Anything would be beneficial. I'm not looking for a quick turnover into a new career. I want to put in the time, but I also can't be hungup for 3-4 years clicking on different programs.

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

    How do I get started with Raspberry Pi?

    Posted: 29 Apr 2021 01:00 PM PDT

    I want to start creating some projects with Raspberry Pi, but I'm completely lost as to how to start. First off, I've got some projects with Python/Django under my belt, so it's my intention to use Python still.

    With the different types of hardware, I'm not sure what I'm looking for in terms of buying something. What is the general setup process to start a project. Essentially what are things someone needs to know starting out.

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

    How do I remove an element from the end of a list without returning the value? (Python)

    Posted: 29 Apr 2021 08:30 PM PDT

    Hi, so I am writing a class for doing some methods on a list.

    I already know how to add an element to the end of a list by using the append() method.

    However if I want to remove an element from the end of a list, without returning the value, how would I go about that? I know the pop() method can remove an element from the end of a list but it then returns the value of that element. What kind of method can I include in my class that will remove an element from the end of the list?

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

    How would I implement some sort of Loop in a Pythagorean Theorem calculator program?

    Posted: 29 Apr 2021 08:06 PM PDT

    So this is my first time making a program and it's for a school assignment. I've got about every requirement done besides one. It asks to show some sort of iteration within the code to count as a point in the grade. And I've been stuck on trying to figure out on how to add it to my program.

    So about my program that I've made so far, its made in a block-based coding website called MIT App Inventor and the program is a simple Pythagorean Theorem calculator. The display shows three text boxes labeled with "Leg 1", "Leg 2", and "Hypotenuse" for the user to input their known values and there's a "Solve" button at the bottom to do the calculations. The program can only take in 2 numbers, so the third textbox that is not filled in will be the number the program will try and solve. So when the "Solve" button is pressed, the program will calculate for either the missing Leg value or the missing Hypotenuse value and will display the answer at the bottom of the screen.

    Now I got the program finished up where it can solve Pythagorean problems quite easily. The only issue I have is meeting the iteration requirement. So how would I implement some kind of For Loop or While Loop into my program?

    submitted by /u/22charly
    [link] [comments]

    How was the web before REST and SPAs?

    Posted: 29 Apr 2021 02:58 PM PDT

    I'm fairly new to webdev world, and like every other beginner I've been following a couple of tutorials here and there and most of them teach you to build REST apis and SPAs. To the point that If i'm given a problem or if I'm to make a project my brain automatically starts thinking about how I'd do it in REST because that's all I know (the shitty kind of REST, mind you).

    For experts out there, How were things before REST and SPAs? is trying to solve everything this way bad? What would you recommend to a beginner who has problems thinking about other paradigms/architectures to build websites and solve problems? If someone's going to recommend a book I'd appreciate books that are more practical and not just thousands lines of text and opinions of the author. Thanks in advance !

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

    The data types long and double are both over 64 bits

    Posted: 29 Apr 2021 11:30 PM PDT

    I got this question in my Java course:

    "The data types long and double are both over 64 bits: True or False"

    So I answered False here is my thinking:

    • Unlike C, Java have exact sized types. From The Java Language Specification, Java SE 16 Edition double and long are 64-bit.
    • In the Cambridge dictionary over means "above or higher than something else" so I assumed it means strictly greater than.

    Turns out I was wrong, the answer is True. I kind of get it but not really could you explain it for me ?

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

    Issue with anxiety of not being able to solve a problem yet

    Posted: 29 Apr 2021 05:26 PM PDT

    Does anyone have advice on how to deal with the anxiety of not knowing how to solve a problem?

    I mean eventually it will be solved but in the mean time there is that anxiety of failure to solve the problem. Any advice?

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

    How to feel motivated to study CS and programming when every program I can possibly think of has already been written?

    Posted: 29 Apr 2021 08:59 AM PDT

    I'm planning on studying CS and programming because I really like the subject and it allows me to work from home which is something I love, but I feel really demotivated on starting it because why would a company ever hire me if there are other people that can do a better job or simply because they can copy a code/use a program that has already been written?

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

    yt channel for cs fundamentals

    Posted: 29 Apr 2021 10:52 PM PDT

    Simply put: Does anyone know a good channel for DSA and other cs fundamentals? Even better if there are implementations in C or Python.

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

    best book for Python Begineers

    Posted: 29 Apr 2021 10:46 PM PDT

    Friends, would you please suggest me some good books for Python learner or if you have ,would you please share it.

    Thank you so much for your help!

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

    Best resources for learning Data Structures in C/C++

    Posted: 29 Apr 2021 10:30 PM PDT

    Title. I am a 2nd year student at university and they are teaching DS in a course here but I really struggled to the point where I dropped the course. I have to take it again but this time I want to go in prepared, so drop your best courses, books, tutorials for DS in C/C++. I know basic C/C++ upto functions and pointers if that helps

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

    How do you 'find out' if a certain functionality exists in a particular programming language?

    Posted: 29 Apr 2021 10:17 PM PDT

    I've begun learning JS recently, and I'm having a weirdly fun time learning everything

    Although, for you senior programmers, I have an important question

    What websites / tools / search techniques do you use when figuring out:

    If a certain tool (code) even exists to solve that problem

    An example:

    Was trying to learn how scopes worked. In the back of my mind, I wanted to figure out how to use variables from the parent scope. A few searches later, I realized something such as closure functions existed. I was mind blown.

    So here's another layer to my question: If I didn't know the 'words' that relate to a problem, such as 'parent scope' - how would I even begin googling for an answer?

    Would love any wisdom. Thanks!

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

    No comments:

    Post a Comment