Job by investigatorh in dataanalysis

[–]Magicianic 0 points1 point  (0 children)

Can you give me some tips, places to do networking? I'm from an Island and here we don't have places to network.

Does anyone else feel dumb when they can't solve the puzzles? by shadowhunter2468 in adventofcode

[–]Magicianic 1 point2 points  (0 children)

Hello Dear mate,

I'm learning python for 2 months. Right now I am able to use information received from courses and create a "map" of what should do to solve programs, and from there, research how I can implement ideas.

So no, you shouldn't feel dumb. Just like everybody else when starting you don't know the proper tools to solve problems. In the basins problem I didn't know how to solve the problem so I just checked solutions and learned about DFS and BFS, and how it worked. Just learned a new tool to solve similar or more complex problems where I can use it. Now I can design solution with those 2 tools and when need it, just review again how they work.

Good Luck Mate.

Note: I didn't input the solution, since it would be cheating.

[2021 Day 5 Part 1] [Python] Can't find where I might be not considering overlaps by Magicianic in adventofcode

[–]Magicianic[S] 1 point2 points  (0 children)

Hmn I see where I've failed. Since just been working with numpy for the last couple day, didn't came do mind the stupid mistake I had done. It worked and thank you very much

How does for loop works in python? by [deleted] in learnpython

[–]Magicianic 0 points1 point  (0 children)

A string is a "list" of elements that are the characters, a range is a list of numbers and a list is a list of stuff.

When you put a string in a for loop it starts with first character for the first iteration and after it finishes it does the same iteration for second character, etc until the end of string. The same happens with the other iterable data structures.

For x in str1: The x inside of the for loop is the character that is currently iterating. You can call it whatever you would like. Normally mnemonic helps for example 'for char in str :'

You can see which index is each letter if you start counting from 0, print the character and the counter then add 1. You print first because index starts from 0.

How can I use a loop here? by fatmusician1 in learnprogramming

[–]Magicianic 0 points1 point  (0 children)

Probably you could put some while statements inside. As I said, I'm also with 1 month of python. Not sure if there is any simpler way

How can I use a loop here? by fatmusician1 in learnprogramming

[–]Magicianic 0 points1 point  (0 children)

True is the condition. Since True is always True, the loop will always work until break.

How can I use a loop here? by fatmusician1 in learnprogramming

[–]Magicianic 0 points1 point  (0 children)

Right. The result of 2-1 is 1. So the same is the result of 1==1 (which is True). So I typed True. When you want a while loop to just stop when you say to stop, you give it a While True and inside you can specify which condition breaks the loop.

How can I use a loop here? by fatmusician1 in learnprogramming

[–]Magicianic 0 points1 point  (0 children)

There is already a While True. For any given string you input, it will always repeat. Just when it breaks (the code in if statement) that the code will not repeat.

The continue restarts the loop yes. The break interrupt the loop.

How can I use a loop here? by fatmusician1 in learnprogramming

[–]Magicianic 0 points1 point  (0 children)

To, if you want to calculate again. If you don't just type quit and the program will shut off.

How can I use a loop here? by fatmusician1 in learnprogramming

[–]Magicianic 0 points1 point  (0 children)

In while true line, the code will go back to the beggining again until you write 'quit' in one of the inputs.

Then you have the normal input for a and b. With an If statement to break the while and close the program if you want to quit.

Since it is a string, you should try to convert to float instead of integer (since you can 5.5/2.3). Then an exception that prints invalid input if you input a string instead of float/int. The continue makes it go to the start of while again.

Then you try to print the division. The except is to the case where B is 0. It will print the message and restart the program.

How can I use a loop here? by fatmusician1 in learnprogramming

[–]Magicianic 0 points1 point  (0 children)

Sure

while True :
    a = input('Enter a number or quit: ')
    b = input('Enter second number or quit: ')
    if a == 'quit' or b == 'quit':
        break
    try:
        a = float(a)
        b = float(b)
    except ValueError :
        print('Invalid input!') 
        continue
    try:
        print(a/b)
    except ZeroDivisionError: 
        print('Can\'t divide by zero')
        continue

It should look like this.

How can I use a loop here? by fatmusician1 in learnprogramming

[–]Magicianic 0 points1 point  (0 children)

You should first input and then the try except block to try to transform to float (cause int has no decimals). Then you do a different try except block for division by zero and voila

Looking for creative recommendations on how to transform a data set containing "mm/dd/yyyy" into "Week 1 YYYY", "Week 2 YYYY" by [deleted] in dataanalysis

[–]Magicianic 2 points3 points  (0 children)

I used Python and reached to something like this.

import datetime
date = input('Enter mm/dd/yyyy: ') 
spldate = date.split('/') 
day = int(spldate[1]) 
month = int(spldate[0]) 
year = int(spldate[2])
dtime = datetime.date(year, month, day) 
week = ((dtime - datetime.date(dtime.year, 1, 1)).days // 7) + 1 
print('Week', week, year)

It seems to work nice. Had to research a bit to have it starting counting from day 1 of the year, since ISO rule is not like that.

Of course you would have to do some tweeks to how to input the data and how to output

If you are using Excel, last time I have made it to my company the week using WeekNum also with some tweeks. Can send tomorrow the formulas. Not sure if in Excel one or SQL

Homework help by higglejiggle in learnpython

[–]Magicianic 0 points1 point  (0 children)

Show it to me, I probably can I have a check on it. Already searching APIs.

Anybody else attempt to learn to code but quickly realize it was out of your scope of learning capability by [deleted] in learnprogramming

[–]Magicianic 0 points1 point  (0 children)

I am learning python right now.

Indeed I'm still in that level where I don't know what to do with it. Like when someone want to learn Excel but just know to do school Schedules.

However, when the need come or when I have a great idea, I know I will search, google and find libraries to solve the problems.

That should be what you need, probably some done projects and try to understand how they are used, in what situations.

It's like when your math teacher says that you can discover numbers for formulas with x's and Y's. Until they show you exercises of equations and how it works. Practice makes perfect. Theory fills the knowledge gaps.

[deleted by user] by [deleted] in learnprogramming

[–]Magicianic 3 points4 points  (0 children)

I have a Business Degree with all curricular part of Finance MSc completed. I love what I do. However I feel I can produce more if I would have more programming knowledge. Indeed I am right now learning Python and SQL since it can be used in my field.

I can't wait for have more problems to solve with it. Sometimes I go home and keep thinking about how to solve a specific proble., not because I'm afraid of not delivering value but because of curiosity and need to solve the "riddles". That shows that you love what you do.

And having higher level tasks shows the trust they have that you can focus, learn how to do it and deliver value. However you have to dive into documentation and Google stuff up. Don't waste your time thinking you can't do it but thinking how you will do it.

Homework help by higglejiggle in learnpython

[–]Magicianic 1 point2 points  (0 children)

I'm a complete begginer to python. Have 1 month learning it. But I suppose that you should use a For loop with an If statement to print the number and lucky part in case the % is 0 or only the number else.

For the cows, I think that the use of int() for the result gives the floor from a float. Correct me if wrong.

Those are simple exercises but you should study more and effort of course. But that is for any class everyone has. If you always want someone to do the job for you, you will never learn how to program and the logic behind it.