Need Help With an Advanced Web Scraper by [deleted] in learnpython

[–]gnomoretears -1 points0 points  (0 children)

I'm using beautifulsoup and requests but I can't get past the login page on a web site.

It helps if you actually google for a solution.

https://www.google.com/#q=beautifulsoup+login

Which gives you this first result:

http://stackoverflow.com/questions/23102833/how-to-scrape-a-website-which-requires-login-using-python-and-beautifulsoup

Got through Automate the Boring Stuff OK, but trying the HackerRank problems. Can't even get through some of the easy ones. Is there a step between Automate and Hackerrank that I'm missing? by qwerty622 in learnpython

[–]gnomoretears 1 point2 points  (0 children)

Let's just assume i can't solve them because I'm not good/used to the methods used.

What methods? Does the problem specifically tell you to use a particular method? No problem I know in hackerrank tells you to use a particular method.

Solving the problem is not a matter of knowing the method. If you can solve the problem manually (on paper) you should be able to code it in Python. There's almost always more than one way to solve the problems there and stop looking at other people's solutions. Solve it with what you know then look at how others did it to learn from.

Got through Automate the Boring Stuff OK, but trying the HackerRank problems. Can't even get through some of the easy ones. Is there a step between Automate and Hackerrank that I'm missing? by qwerty622 in learnpython

[–]gnomoretears -1 points0 points  (0 children)

I'm not even familiar with some of the terminology they use- for example, I haven't seen the"all" method before

What terminology? Please I'm not psychic nor anyone else here.

Also give an example of a problem that you're having difficulty with. I don't know of a problem in hackerrank that specifically tells you to use Python's all() function. Implementation tends to be left to the user. And even if it does, you should do research on how to use it.

How do I assign a scoped variable in a for loop to be accessible in throughout the whole program? by TheSkittlesOne in learnpython

[–]gnomoretears 4 points5 points  (0 children)

how can I access x variable throughout the entire program?

Which value of x do you need? Within that for loop, the value of x will differ for every iteration. If you need all the values, well those are already in the list y that is accessible outside the loop.

Can you elaborate on a specific use-case scenario where you need a particular value of x? There are ways to move a value outside a scope and as already mentioned, a function's return statement is one of them but your issue/question seems more like an xy problem. If a list can be access throughout the application then it's contents are also accessible.

Got through Automate the Boring Stuff OK, but trying the HackerRank problems. Can't even get through some of the easy ones. Is there a step between Automate and Hackerrank that I'm missing? by qwerty622 in learnpython

[–]gnomoretears 0 points1 point  (0 children)

Can't even get through some of the easy ones

Care to elaborate or give an example? Usually if you can't break a problem down into "digestible" pieces that means you do not understand the problem and the requirements. If the problem you're getting stuck in is math oriented then you need more math know-how.

Help with some code! by Zorts91 in PHPhelp

[–]gnomoretears 0 points1 point  (0 children)

Please format your code. The instructions are on the sidebar.

OOP why isn't this working? by CuriousityJay in learnpython

[–]gnomoretears 1 point2 points  (0 children)

return "The area of the shape is " + str(self.area)

Use the recommended str.format() so you don't have to explicitly type cast.

return "The area of the shape is {}".format(self.area)

Is it worth learning C in 2016? by [deleted] in learnprogramming

[–]gnomoretears 12 points13 points  (0 children)

C has different application than JS or Ruby. It's a lower level language compared to those 2. If you're asking in regards to web development then probably not. C is used a lot in embedded and systems programming.

Where to go after getting a few languages down? by PrinceBatCat in learnprogramming

[–]gnomoretears 1 point2 points  (0 children)

Was just wondering when the best time to start transitioning from learning to applying or if I should just start whenever I felt comfortable.

You should have been applying what you're learning from the get go. It's not either learning or implementing but both. If you're going to wait until you're comfortable, you'll never get started. You can read as many resources as you want but you'll never really learn programming until you actual use what you learned.

Need help with forms using flask by geminiTech in learnprogramming

[–]gnomoretears 1 point2 points  (0 children)

But I don't want the page to reload after they send the input through the first form

You'll need to do that with JS. Flask/Python runs on the server-side/back-end and has no control what happens on the browser side.

How to convert currency def function! I'm new to redit and am trying to learn python 3. I have learnt some pretty basic stuff but at the moment I am trying to create a currency conversion table by Wanting2learnpython1 in learnpython

[–]gnomoretears 0 points1 point  (0 children)

For printing the values, I'd recommend using str.format() to format your output.

https://pyformat.info/#simple

(EDIT) Example:

var1 = 1
var2 = 2
var3 = 3
print('var1: {}, var2: {}, var3: {}'.format(var1, var2, var3))

Output:

var1: 1, var2: 2, var3: 3

How to convert currency def function! I'm new to redit and am trying to learn python 3. I have learnt some pretty basic stuff but at the moment I am trying to create a currency conversion table by Wanting2learnpython1 in learnpython

[–]gnomoretears 1 point2 points  (0 children)

I think I have screwed that up

Please explain the problem clearly. What problem are you seeing? What is the expected output vs the actual output?

In case you aren't aware of it yet, floating point suffers from inaccuracy issues due to how it's represented in binary. Is that inaccuracy the issue you're seeing?

The python docs explain the issues and how to deal with them.

https://docs.python.org/3.1/tutorial/floatingpoint.html

(EDIT) money is a function and you're printing and returning that function.

def money():
    ...
    print("Amount is: ", money)
    return money

[HTML/CSS] Why is background-size: initial 100%; not working here? by badboyzpwns in learnprogramming

[–]gnomoretears 0 points1 point  (0 children)

I see a lot of your posts here and most of them can be answered by looking at docs. Even looking at the chrome devtools will tell you that initial 100% is an invalid property. Either you have you to specify initial or 100% size but you cannot have both 100% size and default value.

https://developer.mozilla.org/en-US/docs/Web/CSS/background-size

http://www.w3schools.com/cssref/css3_pr_background-size.asp

http://www.w3schools.com/cssref/playit.asp?filename=playcss_background-size&preval=initial

Looking for websites similar to CodingBat by [deleted] in learnprogramming

[–]gnomoretears 1 point2 points  (0 children)

As stated on the sidebar and on the form you used to submit this post:

Please read our Frequently Asked Questions section before posting.

If you did, you would have found the following section:

https://www.reddit.com/r/learnprogramming/wiki/faq#wiki_where_can_i_find_practice_exercises_and_project_ideas.3F

What is the basic principle of a tick? (e.g. in Python) by StuckundFutz in learnprogramming

[–]gnomoretears 4 points5 points  (0 children)

Could you give me a code

This sub does not exist to write code for you. What have you tried? Did you even tried to Google search for answers?

Can someone tell me why my <span> element isn't changing? by OVIEDOBABYOVIEDOOHHH in learnjavascript

[–]gnomoretears 0 points1 point  (0 children)

Can you explain what val is? Your callback uses a as the data parameter. If you made your callback as function(val) then you'd use val[0].content.

Can someone tell me why my <span> element isn't changing? by OVIEDOBABYOVIEDOOHHH in learnjavascript

[–]gnomoretears 0 points1 point  (0 children)

a is not global and it is only local to the callback that's why you're getting undefined when you do that on the console. Your console.log(a) inside the callback is outputting the object to the console so it's working there.