Not sure what email provider your using but sending to many emails at once can flag your system. Look into breaking them into batches and staging their sends.
I suggest trying HackerRank in order to improve your Python skill: https://www.hackerrank.com/domains/python (or codeSignal/any other platform like this)This however would not be enough for an actual programmer, so, think of problems you'd like to solve in your current life and try doing that with Python.
For example, I got sick of searching if tickets for a show I wanted to go at appeared on a site, therefore, I created a simple Python app that launched at the boot of the OS and scraped that website to see if there were any results for what I was searching.
Your imagination is the limit from here.
<em>Automate the Boring Stuff with Python</em> by Al Sweigart and <em>Python Playground: Geeky Projects for the Curious Programmer</em> by Mahesh Venkitachalam are two good choices to start with.
They both use project-based approaches to learning Python and getting practice.
I'd suggest starting with Automate the Boring Stuff because it's intended to be more beginner-friendly than Python Playground. Then once you complete the first book, move on to the second.
Using those two in tandem should give you a good stream of projects to work on to become more familiar with Python.
My recent story
March: Totally self taught, making crappy sites in PHP. Decided to learn Python.
April: Decided to get a job in Python.
July: Got a job as Junior Software Engineer working in Python/Django.
Last week: Promoted to Software Engineer.
Sooo, 8 months ago I was in a very similar camp, which is why I brought this all up. My plan was to start more web based, do that for work, and learn data science on the side. So similar to you. When I finish this comment, I'll go back to studying.
Books/online course that got me here (In order, except the last two):
For Django: Do the tutorial (I've done it like 3 times), skim the entire docs (yes the entire docs) twice. Read Two Scoops of Django. Make a small Django web app. Don't try to change the world, just something interesting to talk about in your interview. Put the code on GitHub and host it on Heroku for free. List it on your resume. Make sure it has docs and tests.
Good luck!
Download and install PyCharm Community edition. It'll install all the necessary components for you.
https://www.jetbrains.com/pycharm/download/#section=windows
It's really solid. Great debugging features. Python console available right in the app. I use it every day for professional development. (Well, I have the pro version at work, but using community edition at home is really good, too.)
> I'm just frustrated as hell. I've learned some of the basic programming concepts (functions, a little about algorithms, the basics of how object-oriented programming works), but it seems that in order to actually do anything in python, there is a TON I have to learn just to get started at all.
That's any language, man.
Only because I've got years and years of coding under my belt did I find Python relatively easy to pick up. There were still a lot of nuances to it that took me a while to get used to. That said, I was productive with it almost right away. Mostly because it's a good language.
Keep banging away at it. Python is a worthwhile language to learn.
I am currently learning Python (started about 2 months ago) while working a more than full-time job, though I am not new to programming. I use SoloLearn on my phone to practice and study when I have a few odd minutes throughout the day. I took the Automate the Boring Stuff class on Udemy for $10 and doing Colt Steele's course on there currently at night after work. I play around with the challenges on edabit.com and a few other places to reinforce what I have been learning, especially list comprehension.
Pick and choose from here for HTML, CSS, and JavaScript. They do have full WebDev tracks but focused on JS or Ruby on Rails
Read Python Crash course since you have it
Then read Django for Beginners
And you should be set, just start building.
I look stuff up or start tutorials to apply knowledge to what I am trying to build but you won't really learn or be productive if you are not building stuff.
I would probably go with Flask over Django but I don't really know HTML, CSS, or JavaScript and have built a few apps. I just look stuff up as needed or go over some tutorials as mentioned. You will never know everything and will constantly be using docs or Google.
I'm the author of Python Crash Course, from No Starch Press. The book is not available as an audiobook. Over the past five years there are numerous ripoff books that have used the phrase "crash course" in their title. These are machine-generated "books" that gain a high ranking on Amazon by offering a free version and dumping a bunch of fake reviews, and then try to grab a little cash through some paid versions. Here's a clear example of this.
I wonder if OP downloaded one of these fake books. I know my book doesn't work for everyone, but it's really frustrating to watch these ripoff books get in the way of people who are sincerely trying to learn.
Why do you need a Python specific tutorial to learn git? Git and Python have absolutely zero in common.
Use a proper git tutorial, like this to learn git.
A .py file is an actual programme when you run it BUT...
The author of Automate suggested several times a book called, "Effective Python".
https://www.udacity.com/course/intro-to-tensorflow-for-deep-learning--ud187
free course -- not the nanaodegree
go there and scroll down to see the course and project details
udacity has lots of free courses on statistics and data analysis and python
A couple things:
{*range(1, 7)}
doesn't change the result of product
. You can also use the repeat
parameter instead of passing the same value multiple times.
The length of S
will always be the square of dice sides unless you mistyped somewhere. You can eliminate that possibility by using a variable for dice sides.
Comprehensions can have predicates, so list(filter(lambda x : x <= 9, S))
can be changed to [sim for sim in S if sim <= limit]
.
There's no benefit to [*simulate(n)]
over list(simulate(n))
.
simulate
uses a variable not defined anywhere - except in if __name__ == '__main__':
, which defeats its purpose.
https://repl.it/repls/OriginalHilariousDemands (last point is unfixed)
> I've never heard about him.
This statement of yours, coupled with your ranking LPTHW #1 and the Python Cookbook #5 shows that you are definitely not qualified to put a list of recommended books for Python.
They already have a process for bulk signing. Is there a reason you can't use it?
A convenient feature is the creation of templates. If you need to sign documents in a bulk mode, create a blank by adding your name, title, and other necessary data that are repeated in each document.
"eSign Documents Free - Online eSignature Service - DigiSigner" https://www.digisigner.com/free-electronic-signature/esign-document
A web framework is a box of tools designed to help with building websites that are dynamic (not just a bunch of static text files).
Web frameworks are common in many languages (Perl has Catalyst, Ruby has Rails, Java has Spring MVC, etc). Python also has another web framework called flask.
Construction is used as a metaphor for software tools. A basic construction tool box includes things like: hammers, nails, screwdrivers, a rule/level, and saws.
You could construct a building without any of the above tools, but you may spend a large amount of time making tools in order to construct your building. Likewise you can construct a website without a framework, but you may spend time making tools instead of building the website.
Web frameworks can be overkill if you are making a very simple website with only a couple of pages that isn't updated very frequently. If you are creating a website that will be large, interactive, or needs to communicate with services a framework makes it easier.
Django is a big tool box to build websites in Python. You have components like:
Python the language -- you can write modules in Python that can be called in Django to produce output that is then formatted in HTML.
ORM (object-relational mapper) -- This layer maps out a correspondence between columns and rows in a database (like SQLite, MySQL, or PostreSQL) and a data object in Python. This allows you to read and write data from a database without knowing much about SQL.
Templating -- This tool allows you to create dynamic pages without needing to know a lot of Python or HTML. This is useful especially if responsibilities of creating and maintaining the website is split between development (done by programmers) and creative (editors/writers) tasks.
There are other tools in Django but the above gives you an example of things in Django that people find useful.
Send a HEAD request.
e.g. using requests
>>> import requests >>> resp = requests.head('http://www.python.org') >>> print(resp.status_code) 301
This book is absolutely the most incredible thing I've come across so far. I started out using Code academy but honestly I kept getting bored with how linear it was (In my opinion) and honestly I personally learn better when I can take the bite sized pieces and do what I want with them which is what this book does.
It defines the function simply, gives examples of how it's used and then a visible representation of the function in action, and after that it'll give you exercises (that I like to customize) that you can try yourself. I'm only on chapter four which introduces loops but this book goes everywhere with me along with a journal to physically write down code and then test it when I'm near a computer.
There are other books in this series but I refuse to overwhelm myself with too many books at once.
I'm aware not everyone retains information the same way but if you'd like I can post pictures of the layout of the book so you can get a feel for it. I'm fairly new to Python and it is my first language (although I did look into Javascript, CSS and HTML first but didn't actually retain it as well. I intend to go back to those after I 'master' python.)
Sorry for the book of a comment! I got excited...
One thing I'd like to add to that is the indentation width -- OP seems to be using 2 spaces for indentation, while the recommended size is 4 spaces.
Actually, I recommend for OP to check out an IDE (Integrated Development Environment, example -- PyCharm) that does style checking, and then run this project in it. All style errors will be visible immediately.
OP was able to successfully communicate the program to his computer, now it's up to them to do the same for humans lol
Project Euler has been mentioned.
I also like http://exercism.io/. Project Euler is all about the math problems, exercism has you doing more varied stuff. I haven't done the Python tasks myself, but presumably they are similar to the tasks in the languages I have done.
If you have a smartphone, you might like Pushbullet instead. It's a notification app with an API that basically lets you pass messages between your devices.
There's a few Python libraries for working with it-- I use this one. Once you set up Pushbullet and get an API key, you can push notifications as simply as this:
from pushbullet import pushbullet pb = pushbullet.Pushbullet("Your API Key") pb.push_note("Test Message", "Hello world!")
I'm told that Dash is the new hotness. It'll let you do all your visualization work in python and it'll spit out a React page. Not having to deal with Javascript is a win in my book.
Other than that, you'll need to learn Numpy, Pandas, Scipy, and Scikit-Learn at a minimum. Get comfy with how those libraries work and you'll be in an excellent position to be successful as a data scientist. Load up on Probability, Statistics, Linear Algebra, and Calculus (particularly multivariate calc) classes. Do well in your programming classes and work hard to learn some Software Engineering best practices. Hopefully, you can take an AI or Machine Learning class or two. See if the math department has a class that covers the mathematical foundations of ML, too, for an in-depth understanding of the algorithms. Oh, and if you're into doing the visualizations, maybe an art class or two wouldn't hurt, honestly. Maybe that's just me talking, though. I have a great deal to learn when it comes to the artistic side of things; whereas, maybe you don't.
I use digital ocean
I think you get $10 credit with my link
https://www.digitalocean.com/?refcode=6de208ecb9dc
Set up the $5 per month Ubuntu LAMP stack.
Install Putty (windows) to connect to your VPS IP address.
sudo apt-get install python-pip
Then you can run Flask if you want
https://www.digitalocean.com/community/tutorials/how-to-deploy-a-flask-application-on-an-ubuntu-vps
Use WinSCP to manage your files.
CheckiO is a good place to go for challenges and to see some other code, if you don't mind learning by doing.
Project Euler is a good place if you want to get some practice with algorithms and efficiency. (ETA: this one is rather math-based, but the challenges vary greatly in degree of difficulty)
Excellent starting point, but I think a DBA would find it lacking, as it doesn't really cover data structures or packages very well. I would pick it up to get your feet wet, but not read it cover to cover.
Look for something that covers Pandas and SQLalchemy. Check out Python Data Analysis, Python Data Science handbook. They are super modular and approachable.
Python is definitely a good language for that. A few people mentioned BeautifulSoup, which can be used to parse HTML. If you want a full scraping framework you should check out scrapy.
Your friend will only be able to run your code if they have a compatible version of Python installed on their system. You can send them your .py file(s) to run on a Python installation.
Unlike languages such as C that are compiled to an executable machine code that can be run on compatible platforms (e.g. Windows 10 on Intel/AMD processors), Python is an interpreted language and requires a Python environment for execution.
There are programmes around that will attempt to convert Python code to executable code but these have compromises.
Alternatively, you could make the code available on a website like repl.it where it can be run in the browser or on a service like that offered by Python Anywhere. Free options for both.
I'm not sure when it is, but there's a book called Introduction to Algorithms which is basically the handbook and go-to guide for anything you need to know. This has all sorts of data structures and CS concepts. I'd suggest reading through and just being familiar with the concepts up to chapter 24 or so.
I came to Python after some experience with PHP (which I mostly learned from the Head First book). I started with the website Learn Python in Y Minutes, then the interactive websites How to Think Like a Computer Scientists and Problem Solving With Data Structures and Algorithms using Python, which are both based on books.
I've also read Effective Python, Python Cookbook, Python 3 Object Oriented Programming and am now working on Fluent Python.
Anyway, I really, really like books. I figure every good programming book I read is worth at least $10k in lifetime earnings. What made learning from books effective for me was I started working on my own projects right away and would use the books as reference.
I think building knowledge is like building a brick house. Books and online courses are the bricks, blog posts and stack overflow answers are the mortar. If you only have bricks, your knowledge is brittle and full of holes. If you only have the mortar, it's just a pile of mush and you can't really build anything.
I like every book I just described, in the order I did them. I also read Code while I was at it. I like Hackerrank for small challenges. The Hitchhiker's Guide to Python is great to read before your first project.
Another option that might work is measuring the power draw of the laptop. You could use a sensor like this connected to a raspberry pi to detect when a computer is turned on.
If you don't have a project in mind that you want to start, I'd recommend something like Codwars. Or, if you're more mathematically inclined, Project Euler. Both of these will give you mini-projects to introduce you to problem-solving via programming, and scale up from pretty simple to really tricky.
I don't want to be mean. This project looks like something one person can manage alone, but not someone who needs to ask about Flask vs Django.
If you choose this path, you may need Python, but also some JavaScript, HTML, CSS, a bit of servers...
If you want to start making money with this, I recommend you to start with serverless architectures, AWS (lambda, cognito, aurora...), React for FrontEnd, etc.
This is (and I will get angry replies for this) much flexible, robust and cheap than Django sitting in a server (I worked with Django for 4 years, so my opinion counts)
This is the option companies like Netflix and AirBnB uses, and Amazon, Alibaba and others are migrating to.
I am half way through Problem Solving with Algorithms and Data Structures. It is an extremely well written book. It explains the fundamental data structures (queues, stacks, deques, trees, graphs, maps, linked lists, and more) and algorithms (breadth first search, recursion, traversing trees, search/sorting, hashing, caching, priority, and more) in great detail.
I'm half way through it and honestly I had no clue what on earth data structures and algorithms was, now I am way more knowledgeable. I solved every single problem in the textbook so far and each problem is presented in such a way that it utilizes material from previous chapters and encourages synergizing different concepts.
Your life will be so much easier once you learn git. Trust me, its 100% worth it to do so. If you're on Windows you can install it from here, if you're on macOS, type git
in the terminal and hit enter to install it from xcode, and if you're on Linux just install it with your package manager. I found a really easy to follow git tutorial here.
Imagine being able to save all past states of your code, and being able to revert to a precious version if you completely mess up. You can do that with git. Again, trust me, git will make your life so much easier, and employers will like if you can use it
There is actually a great book I read called The Python Workbook by Ben Stephenson it has almost 200 hundred specific exercises to teach different applications of Python and I've found that it can be used as an example or basis for practicing using other languages too!
EDIT: link to book on Amazon
Anglea Yu's 100 days of Python course on Udemy.com has been incredible. Every day you work on a new project. Yesterday was tracking ISS, today I'm building a trivia game using an API. Highly recommend.
Yes, from the py2exe tutorial:
>py2exe turns Python programs into packages that can be run on other Windows computers without needing to install Python on those computers.
I recommend JetBrains PyCharm. It has great debugging features and is easy to use. They offer a free community version, which has most of the features you will need to start with and then there is a professional edition which has more features.
do exercism.io python track up to challenge 35
This should suffice. Say 1-2 months work if you are new to programming.
You can use Godot and it's very python-like scripting language, GdScript, to make very powerful games.
If your game doesn't need to be very graphically intense in a beautiful 3D world making all the use of a good graphics card, then it's perfectly possible to make a nice game with it, and in some ways getting the game logic can be a lot easier.
How about this book Think like a programmer. Have a looksie.
Edit: For your problem you could use reverse planning: Start at the end with the result you want and work backwards.
[Python Cookbook](chimera.labs.oreilly.com/books/1230000000393/index.html) is another great resource for a bunch of recipes for topics like
You will probably need at least two things:
1) Your own domain. There are various ways to go about this and I won't attempt to explain them all.
I would suggest maybe starting here https://domains.google/#/. I haven't used this service personally but have heard pretty good things.
2) You will need a web server of some sort. Digital Ocean, Linode, etc. I have used a Digital Ocean VPS in the past and they have a "one-click" install feature for django apps. This web server will have an IP address assigned that can be used to access your website publicly. Your VPS can be further configured to work with a domain that you own.
Neither one of these tasks is easily explainable via text. I would consider looking over a tutorial of some sort, I have used this site (Belongs to /u/sentdex) in the past which includes a guide on deploying your finished django app to a Digital Ocean VPS.
There are bound to be other methods but this is where I have had the most success.
Please choose one option: :
a) make a text based game for PC and for Android
b) want to take one step further in Python
If your choice is "a" - use the Instead engine.
If your choice is "b" - use the RenPy engine.
Hi there! I used cybrary.it after learning the basics to help me get more in to security, and they do have a course specifically for Python. The website is free to use, and I personally enjoyed it a lot when first starting out:
Flask has the code inside requests isolated from one another generally. You should read this section to get a better understanding of how Flask separates data between requests: http://flask.pocoo.org/docs/0.10/quickstart/#context-locals
The main worry with race conditions such as this is when dealing with 3rd party sources, such as a database. As they might both attempt to write the same data to a database (and only one record should exist), you should put safeguards in place such as locks, unique constraints, or similar checks.
The code inside the request / view function itself is not in danger of suddenly overlapping data-wise between the requests.
Do you have a specific case in mind?
I am new also. A am using the book Python Crash Course
https://www.amazon.com/Python-Crash-Course-Hands-Project-Based/dp/1593276036
and it is quite helpful so far. I am going to finish the whole book and type out all the exercises
I would advice you to first see what you want to achieve using Python. Initially you could resources like codecademy.com or book like "Automate the Boring stuff" and "Fluent Python" to get good understanding of Python. There is also Python Cookbook which can help you figure out what you can achieve with Python.
And yes doing a project is the right way to go. And you will know about the existing python modules only after researching thoroughly in a particular domain. Like for example in data science there is pandas, scipy, matplotlib etc. If you go to web you will come across frameworks like Flask and Django and with it the required dependencies based on features you want to implement within your web app or databases your using etc.
Python base is pretty huge so more often then not you should be able to find packages out there, so don't be afraid to explore. And if you need any help, you can always ask on reddit or twitter or irc channel. There is large community out there who are willing to help. So good luck. Happy exploring!
I recommend Flask
You can start with this tutorial: http://flask.pocoo.org/docs/1.0/tutorial/
Another tutorial: https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world
The first tutorial should be enough to get started but the second link is also helpful
I really think this is your best bet:
http://www.qtrac.eu/pyqtbook.html
I used it to learn PyQT and successfully wrote an app using it. I found it easier than other gui frameworks, too. PyQT's docs are good, but they are good once you know what is going on and not in a way to learn how to use the tools.
This also sums up some resources/ideas about what you need to do some QT programming.
Virtualenv is a tool that lets you set up self-contained Python installations in a folder, with their own python
binary and libraries/pip packages. This is useful for keeping separate Python applications isolated, so that updating the dependencies of one application doesn't affect the others.
In contrast, pyenv just allows you to easily switch between which version of Python is launched when you run python
(on a per-user basis). Most systems have both Python 2.x and 3.x installed, and some may also have 3rd-party interpreters such as PyPy, IronPython, etc.
EDIT: I talked about the difference between virtualenv and a project on GitHub called py*env*. /u/Rhomboid's comment discusses py*venv*, if you're wondering about that.
Generally, you’d want to give them the python file and they’d have python installed. There are tools for this though.
> Are there tutorials for these?
Of course!
Just google 'modulename tutorial' for almost any major package and you will probably get numerous results. It is fairly routine for major 3rd party modules and packages to have a 'how to'/'introduction'/'getting started'/'tutorial' in their own documentation. For instance, here it is for PyGame.
But tutorial or no, referencing the documentation and google searches are critical to learning modules and even programming in general.
Also, for the standard library in particular, Python Module of the Week is a cool reference.
I really enjoy Codewars.
You're given a simple programming assignment to solve; once you've accomplished it and it passes all the tests, you get to see how other people solved the same assignment. You'll almost always pick up something from those solutions that you didn't know before - either about Python in particular or design patterns in general.
While people do create complete packages with all those files you listed, you don't need to make a project more complicated than it needs to be. Sometimes, making a package with many modules, etc. is what a project requires. Other times, one or two short scripts might be all that's necessary.
I think one of the best ways to make your work more presentable (besides writing good, clean, modular code) is with a polished README. The README is the first thing anyone who clicks on a repository will see. So I would recommend learning some basic Github markdown (see https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet) and learn how to write a good README (see https://github.com/matiassingers/awesome-readme for examples).
'\n' * 8
is 8 newlinescheckGuess
are nuts. I recommend a while True:
loop and move all the checks inside. return
when a valid input is given.guessInfo
that I recommend refactoring.correctWrongTracker
, instead of a = 1
, use pass
. But actually, invert the condition and get rid of the else
.again
just return True
or False
?I just found codewars - I havn't done a challenge yet but it looks like you get challenges to solve and then you can compare your results to others.
What I like about this is that I saw one example where the first guy had a bunch of lines of code, the next guy had a for loop with some conditionals, the next guy turned that into list comprehension one liners and the next guy basically used a method on the data structures to solve the problem. Amazing what people can do and I want to be that cool too. It also times the code to see how efficient it is. And it has many languages.
Has anyone else used it?
I'm going to give you the benefit of doubt and give the links, but I need to point out that it would have been quicker for you to Google it yourself than ask the question here on Reddit...
Python: https://www.python.org/downloads/
PyCharm: https://www.jetbrains.com/pycharm/
There's Godot, which doesn't really use Python, but their custom language is heavily influenced by Python. However, there aren't really any good 3D engines using Python itself.
If you're just learning though, it's important to learn the concepts, which you can do in any high-level language, really. If you're familiar with how programming works in general, you can translate that knowledge to a new language just by learning its syntax.
While Vim and Emacs are great, they have their own learning curve, and if you are a beginner programmer, it could be annoying to be learning both the language and editor at the same time.
You can try by moving to a code editor first. I am hearing good things about Visual Studio Code these days, Sublime Text is also quite famous.
Once your skills as programmer have improved a bit, you can give Vim/Emacs a try and see what suits your needs better.
I highly recommend Udacity CS101. You won't be bored!
Then Udacity Web Development...taught by Steve Huffman, founder of reddit!
Can't say enough about these! Worth the money!
My favorite website is definitely http://www.codeabbey.com/
It allows you to try problems in multiple languages and you have to start each problem from scratch (instead of just writing methods).
Also after you solve a problem, you are able to view others solutions which helps expands your know-how!
At 21 you're really grand, I teach everyone from 13 to 70 how to program and there's really nothing stopping you becoming proficient now, the societal expectation to know exactly what you want to do in life by your early 20s is bs, just keep moving forward :)
I'm not sure which course you're taking particularly but it's important when learning to program to have consistent exposure to kinaesthetic experience. Tutorials are nice but there's a danger of binging them, which unless you've got an incredibly good memory usually leads to quite a lot of gaps. I'd suggest continuing your tutorials but also checking out something like code wars (https://www.codewars.com), which will give you practical experience. Remembering something like the syntax of a loop is difficult if you've only experienced it in a tutorial, but when you're using it to solve the tenth challenge of the day, it becomes as plain as English. Also never be afraid to Google, it exists for a reason :)
Beyond that I'd suggest once you've got the fundamentals under your belt, trying out a project. That could be anything you're interested in, particularly if it's relevant to a specific field. So for example I teach predominantly Linguists so I get them to experiment building language search tools, translators, and things like that. If you're interested in the web you could build a basic website, AI you could build a classifier etc
Code Wars doesn't seem to have anything to do with interview practice, at all.
It's also a wonderful site, having a ton of languages and problems ranging from super-easy newbie stuff, to fun like this.
I would recommend using a dictionary. If you don't know, a dictionary is like a fancy array. It allows for very fast access of data using a key. A key can be any String or number.
periodicTable = { "H" : 1.0008, "He" : 4.0026, "Li" : 6.9400 } print(periodicTable["H"]) print(periodicTable["He"]) print(periodicTable["Li"])
For the Math here, use the following syntax.
totalMass = 2 * periodicTable["H"] + 3 * periodicTable["He"] print("2H + 3He = " + str(totalMass))
Additionally, you can store even more information using a dictionary of dictionaries. Keys are element symbol
periodicTable = { "H" : { "Name" : "Hydrogen", "Atomic Number" : 1, "Atomic Weight" : 1.0008 } } print(periodicTable["H"]["Name"]) print(periodicTable["H"]["Atomic Number"]) print(periodicTable["H"]["Atomic Weight"])
Or you can use the name as the key:
periodicTable = { "Hydrogen" : { "Symbol" : "H", "Atomic Number" : 1, "Atomic Weight" : 1.0008 } }
OR you can use the atomic number as the key.
periodicTable = { 1 : { "Name" : "Hydrogen", "Symbol" : "H", "Atomic Weight" : 1.0008 } }
I think you get the idea! NOTE the COLON (:) not equals (=) in the assignment inside a dictionary. Check out this link for more technical information on dictionaries.
Feel free to ask any questions you have about this approach! Hope it helps.
I would use pycharm
Each time you make a new project it will ask you which python you want to use, if you want to create a virtualenvironment for it, it will help you with your code, show errors, warnings, you can execute part of your code, debugging, access terminal...
Very clean for beginners
"Algorithms Unlocked" is a good itnroduction to algorithms, which is written by the same guy that was a co-author on the college-standard algorithm book (aptly called "Introduction to Algorithms" by 4 authors known collectively as CLRS). There's actually a couple free "lesson plans" for the Algs book that gives you a good guide of how to read through it rather than chapter by chapter.
My suggestion would be to get a Linear Algebra book, a Calc book (my personal favorite is Stewart's Early Transcendentals) , and then these 2 algorithms books. Then devote a day to each. You'll come out with essentially a CS degree minus the actual programming experience which you can pick up in a few months.
Don't use cron for this. Use your init system, use a proper server, and put a proxy in front. This guide explains everything.
I can vouch for https://dataquest.io or http://www.codecademy.com/tracks/python
If after this you want more, go for a proper MOOC on Coursera, ideally on a theme you are interested in (Finance, Biology, etc).
I suggest you start NOW a Github repositery because any tutor will want to see your code and easily share fix or ask questions. Use the wiki for your notes, use the repository itself for your code.
If after all this done you are still up for it, in July I could tutor you for one hour per week in exchange for... I don't know yet but as you said nothing illegal.
My suggestion would be www.udacity.com, find the free course for introduction to computer programming (it's done in python). I find that they have a much better course structure and will keep you motivated much longer than pointless, arbitrary codeacademy.
EDIT: here's the direct link https://www.udacity.com/course/intro-to-computer-science--cs101
I really like using them to 'register' functions. Flask is a great example that uses them for just this: http://flask.pocoo.org/
You 'decorate' functions with app.route('/url')
, so that whatever function you decorated, is called when that url is requested - lovely.
Here's an indication of how it works:
class FuncStore:
def init(self): self.funcs = []
def register(self, f): self.funcs.append(f) return f
fs = FuncStore()
@fs.register def my_func(): print("Mine!")
print(fs.funcs) # [<function my_func at 0x0000018D682A2E18>]
The other classic example is a 'timeit' style wrapper, that measures the time it takes to execute whatever it wrapped:
import time
def timed(f): def wrapped(*args, **kwargs): start = time.time() res = f(*args, **kwargs) stop = time.time() print("Execution took {} secs".format(stop - start)) return res return wrapped
@timed def long_thing(t): time.sleep(t) print("Slept for", t)
>>> long_thing(3) Slept for 3 Execution took 3.0013415813446045 secs
This link may be helpful:
http://www.tutorialspoint.com/python/python_classes_objects.htm
Also, a simple google search for Python OOP can yield promising results, especially if they are .edu links.
edabit.com for a nice range of problems to solve. It also gives you links to documentation/resources that are relevant to what you are solving and also shows you what other people have submitted as answers.
sys.exit()
is the the best option for terminating a script. exit()
and quit()
, which serve the exact same purpose, should be used in the interactive interpreter.
Make an image of the drive using dd. In that case you do not have to use the card and destroy it on accident.
You can use Photorec for trying to recover your data. Might work and save you a lot of time.
No, completely different.
A hyperlink is a link you can click on a web page that takes you to another web page.
xpath is a way to navigate, drill down and select specific nodes of a structured document (like html, or xml). For example if you have an html document like
<body> <table> <row></row> <row></row> <row></row> </table> </body>
And you want to extract just the second row of the table, you could get there with this xpath string:
/body/table/row[2]
This is how you will tell selenium which things in the webpage to click on, for example. I believe selenium also supports selecting via css selectors. https://saucelabs.com/resources/selenium/css-selectors
A Python process only makes use of a single CPU core, so in this era when low-end laptops (and even phones) have multiple cores, there are applications for which that's kind of annoying.
Writing correct programs that handle parallel execution is a hard topic in any language, but some approaches just haven't been doable in Python at all.
(You can run multiple python processes that run at the same time and talk to each other, but that's not quite the same thing.)
Pypy is doing some very interesting research in this area, but that branch of pypy is still very much in research mode. Promising but not yet usable.
I'm guessing this might have something to do with it:
> Really short-running scripts: A rule of thumb is if something runs below 0.2s the JIT has no chance, but it depends a lot on the program in question. In general, make sure you warm up your program before running benchmarks, if you're measuring something long-running like a server. The time required to warm up the JIT varies; give it at least a couple of seconds. (PyPy's JIT takes an especially long time to warm up.)
From here.
There is pythonista on iOS, which does actually allow you to do quite a bit, though it runs inside a sandbox and doesn't have access to phone functions, which would be a security nightmare.
Manually, which is probably possible with only few items to add or edit I am using sqliteman which is quite old but it seems that newer alternative could be http://sqlitebrowser.org/
Thank you so much for this, I'm teaching python on a government-sponsored program on a third world country, and this helps a lot.
You removed the ISIC card requirement, isn't?
EDIT: Can I make my own/edit the existing lessons? I would like to translate the lessons to Spanish
EDIT2: I'm just reading the "Getting Started for Educators" doc, this is great
For a more detailed discussion on tabs vs spaces, check this article out.
>... it can be a good idea to avoid tabs alltogether, because the semantics of tabs are not very well-defined in the computer world, and they can be displayed completely differently on different types of systems and editors. Also, tabs often get destroyed or wrongly converted during copy&paste operations, or when a piece of source code is inserted into a web page or other kind of markup code.
Having a mentor and an open mind is the fastest way to improve. Have you considered asking your colleague to coach you? Since it sounds like you've already got your fundamentals and mechanics down, having her review your code and explain what can be improved will probably be the most helpful thing for you.
I say you need an open mind, because it's easy to become arrogant and close minded to other opinions. Remain flexible in your views and be open to change - it'll help accelerate things.
My last piece of advice would be to read some of the classic books in software engineering. "Design Patterns" by the Gang Of Four, "Programming Pearls" by Jon Bentley, and "The Pragmatic Programmer" by Andrew Hunt are some of my favourites.
Take MITx: 6.00.1x on edx.org and read Learning Python. IMO, Fluent Python is more advanced than Effective Python, but you can decide for yourself before you buy any of the books. You can check out Python Cookbook, Fluent Python and Learning Python at www.safaribooksonline.com, get the 10 day free trial and look through the books.
Here's an article that answers some of your questions: Understanding Class and Instance Variables in Python 3. Check out the related tutorials, on that site, too.
I suspect though that you're not really going to be satisfied with it, particularly since you ask "Why is the code always repetitive like self.'ex'" - so, from here on out will be my sleep-deprived ramblings.
The core of the reasoning behind self
is that you can't manipulate an object unless you have a reference to that object. Since a class is fundamentally a bunch of functions that manipulate a particular kind of object, all those functions are going to need a reference to the object they're manipulating.
Rather than coming up with new syntax or semantics to represent "the object I'm manipulating", Python just passes it as a parameter. And for the sake of consistency, programmers always call that parameter self
.
Other languages like C# and Java actually do the same thing - they just have special semantics and syntax in the form of the this
keyword. Python just opts to not have those semantics for the sake of consistency and simplicity (of the programming language, not necessarily for the programmer).
There's also a critical difference between a constructor, which creates a new object, and an initializer, which puts an existing object into a working state. __init__
is an initializer. It takes in an object, self
, and puts it into a working state. Typically in Python all that's needed in this step is to give that object some attributes that the other methods assume an object of that type will have.
You can actually create a constructor in python - __new__
- but this is hardly ever needed due to Python's dynamic nature.
Sure, here's a quick example. And yes, please use a parser or you're as bad as someone parsing html with regex
pip install xmltodict dicttoxml ilio
Now put your first block into a file, call it animal_friends.xml
or something like that.
import xmltodict, dicttoxml, ilio
raw_data = ilio.read('animal_friends.xml') data = xmltodict.parse(raw_data) dog_name = data['Animals']['Animal'][0]['Dog']['Name'] data['Animals']['Friend'] = dog_name del data['Animals']['Animal'][0] xml = dicttoxml.dicttoxml(data, root=False, attr_type=False).decode() ilio.write('animal_friends.xml', xml)
It works the same as yours but uses parsers to do it cleanly
Never. Ubuntu does not include feature releases in LTS updates. You can get 3.6 from the deadsnakes PPA, but the entire system won't be switched to it ever.
Dont try to do it this way.
Instead, use some well known software (gunicorn, nginx) that can already do this and pass requests off to your Flask app.
Here's a good tutorial: https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-gunicorn-and-nginx-on-ubuntu-14-04
check coursera introduction to python week 1 is about to finish but you can still join and learn everything they teach, it's completely free with an optional paid verified certificate
You wouldn't, and Python would do it for you since after that line executes there are no further references to the result of open().
However, it's not good practice, and you should probably use the more commonly accepted context manager for files.
with open(filename) as input_file: indata = input_file.read()
As for what to google, I searched python open read one liner
and got this result which agrees with me.
Because the pointer has a type - this is what I was getting at in the next line. In reality, foo
is not actually the int
12304568
, it is the int*
(int*) 12304568
. Just like, were foo a double
, it would be the double*
(double*) 12304568
You can move the pointer 1 byte by casting it to a char*
and back. See here: https://repl.it/repls/FragrantSplendidGlobalarrays
You can also see some non-intuitive stuff going on because, apparently, repl.it's machines are little-endian.
Nginx is a web server and gunicorn is an application server. Usually nginx works as a proxy to the application server, but serves static and media files. You need something that executes Python but Python isn't the best at handling all types of requests.
I haven't used them, but Udacity offers what they call "nano degrees". https://www.udacity.com/nanodegree
Edit: Sorry, I don't think they specifically offer one for Python, but some Python appears to be incorporated into a couple of the degree curricula.
Sounds like you want Flask really.
You could do it with Django but IMO Flask is much easier to pick up as a newbie. In this case you don't need any of Django's extra features, and the structure will just slow you down. If you wanted to convert your app to Django later for a learning experience it'd be trivial too.
You could probably just read chapters 1-3 of this tutorial and know enough to write your app:
https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world
Also worth reading:
http://flask.pocoo.org/docs/1.0/quickstart/#quickstart
If you already have the functions written you could probably learn enough Flask to get your urls/templates written in a few hours from scratch.
> Imho this is certainly not what you should use in everyday code because it overcomplicates stuff much more then it optimizes anything.
This doesn't seem to optimise anything either. Briefly playing with runtimes (not that reliable on a cloud service like this) it appears to be roughly equivalent to or fractionally slower than just using an if
statement, while obfuscating the code and not gaining any substantial brevity. The dictionary version is more verbose and notably slower. I'm struggling to think of a halfway sensible use case for either of these two approaches.
The slowest version there is using min
, but that is generalised to find the lowest value in any number of arguments while the others just pick lower of two.
Simple.
I created a discord bot that helps you interface with https://openweathermap.org/
You would type something along the lines of "weather in Dallas". It would not only fetch weather in Dallas, but would cache the request in case someone else in another discord chatroom would like to access data on Dallas. It gave a 5 minute timeout for the cached results.
I somehow obtained these statistics for internet usage in the following cities:
Budapest 7,498,044
Prague 8,400,059
Berlin 71,727,551
London 59,333,154
Vienna 7,135,168
Paris 55,429,382
Rigga 1,628,854
Tallinn 1,106,299
Helsinki 5,117,660
Warsaw 25,666,238
Lisbon 7,015,519
I then created unfair dice to simulate a request from one of these cities( along with some timezone related dilation that peaks at Noon and 8pm)
I then ran this simulation for about a day against another requester that counted the total number of requests.
I then created visualizations and printed statistics about how much we saved in terms of request volume by implementing this caching.
The caching reduced the number of actual API requests made to 20% of the requests the original one made. I then laboriously linked the reader to more resources on caching.
Overall, The project demonstrated:
Look into using virtual environments, they are exactly the reason they were made when you dont want to mess with your system level Python setup. There a few different virtual environment managers but my favorite is miniconda.
Try psutil:
pip install psutil
Then it is as simple as (using vlc in my case):
for proc in psutil.process_iter(): if proc.name() == 'vlc.exe': print(proc.open_files())
:)