Articles of the Week

Pubbies of the Week

You Think Sets Are Hard but They Actually Aren’t

Categories: General, Tech | Pubby Cash Received:  0

Similar to a list, a set is a collection that is unordered and unindexed. In Python, sets are written with curly brackets. The difference from lists is that you cannot access items in a set by referring to an index since sets are unordered the items has no index. However, you can loop through the set items using a for loop, or ask if a specified value is present in a set, by using the 'in' keyword. A Python set also resembles a dictionary because it cannot have duplicate values. This makes it easy when you want to store usernames from your website. When a user wants to create a new username, the program will first check if that username is in the set, and if not, then it will add the username to the set. One thing that surprised me was that sets were unordered. You might expect an item to be at that location when you add it but that’s not always the case. Since sets are unordered, so you cannot be sure in which order the items will appear. Unfortunately, you cannot change a value in a set, only add to it. To add one item to a set, use the ‘add()’ method. Use the ‘update()’ method to add more than one item to a set. Sets are easy to work with once you get the hang of it!...  Read more

Hard-to-find Tiny Bugs in Code

Categories: Tech | Pubby Cash Received:  0

Based on my limited coding experience, I've summarized my top three tiny bugs that have wasted many of my valuable hours. I would like to share with you all so that you can avoid them by all means. No. 1. Punctuation and Spelling. A mistake of missing a comma would either cause an immediate trackback or temporarily got accepted but blow off your code in future. I had a field in a database table storing a list that is dynamically being appended, say [1,2,3,4,5,] and has been converted to string. Note that the list is ended with a comma in the square brackets. That comma costs me hours to make things at other places work as planned. Spelling is another thing that can be easily overlooked. When I was coding to communicate with a database via SQLAlchemy, I typed db.session.commmit(). That triple m drove me crazy when I found out with my old eyes. No. 2. Indentation. Tabs and white spaces are treated differently in Python. This is especially true when you are trying to copy a code snippet from elsewhere and paste it into your program. You thought they are identical and should work flawlessly. However, the cruel reality might be that you just cannot make it work. Tabs and white spaces cannot be distinguished by naked eyes. It takes me hours to find out that the Sublime Text editor has a function of converting all tabs to spaces, and that solves my problem. No. 3. Data Types. Operations with values of different data types will throw out an error. Although it is not difficult to realize that datetime and timedelta are incomparable, and strings are incomparable with other data types, the problem is: sometimes, it is visually impossible to tell the difference between a string and another datatype! Let's say x = 2. Now x is an integer. Then let's say y = str(2), and now y =2, too. But this "2" is different from the previous "2", because this "2" is a string. If you run x + y, it will throw off an error! The recommendation is: always check the data types to make sure you are well informed. If you are trapped in debugging processes, you could try to target on the above-mentioned three hard-to-find bugs. Hope this will help you out!...  Read more

This Data Structure Is Underrated!

Categories: General, Tech | Pubby Cash Received:  0

Let’s say that you needed to create a list of all the users that have been banned on your site. Many programmers would just use a list, and that’s just fine. They would insert a tuple containing information about the first user and the time banned, then continue with the second user and their time banned, and so on. If they want to remove a user from the list, they could either use ‘pop’ or ‘remove’. Additionally, if they want to update an item in a list, it can be very difficult because there might be multiple items with the same name. Basically, using a list isn’t the best way to go when it comes to storing lots of data that is easily accessible. So is there an even easier way? The answer is yes. Dictionaries are very beneficial in this situation because each item stored in a dictionary is unique. If you want to remove an item from a dictionary, all you have to do is find the key and delete it using the ‘del’ keyword followed by the name of the key. It’s that simple. And if you want to update an item in a dictionary, you can simply call that item using it’s key and set that to your new value. Many programmers underestimate the power of dictionaries and often turn to lists because dictionaries are just a little more confusing. But trust me, once you get the hang of dictionaries, storing data will feel like a breeze....  Read more

Lenovo Multimedia Remote with Keyboard N5901

Categories: Tech | Pubby Cash Received:  0

Do you like mini keyboards that can do everything on a computer? Well, the Lenovo Multimedia Remote with Keyboard N5901 is the right thing for you. This product is comfortable and efficient. This product is comfortable because it fits your hand very firmly. There is also a mini ball at the bottom of it. This ball acts as a trackpad or a mouse on a normal computer. When I was using this it felt very comfortable because the ball felt very smooth. Furthermore, the left and right-click above the ball is easy to use as well. Also, this product is efficient. After all, you can do anything you can do with a keyboard on it. There are even a sound button and a pause and play button at the very top of it. All in all, the Lenovo Multimedia Remote with Keyboard N5901 is very useful and is worth buying. ...  Read more

Be a Trader in Real Stock Market with Your Pubby Cash

Categories: Tech | Pubby Cash Received:  0

Stock trading is about economics. This is also a skill that one definitely needs to master in the modern world. I'm glad to find that the GoPubby stock trading market is online. You have a selection of trading over 20 stocks with your Pubby Cash. The stocks on the market right now are choices of brand company names covering a variety of sections including technology, consumer goods, health, finance, energy, transportation, utilities, and so on. The reason I say this is real stock market is because you will be trading at real-time stock prices. For example, one share of Facebook stock costs 240 right now, you will be able to buy it at 240, and of course, the currency is not in US Dollars, but in Pubby Cash. After refreshing the page, if the stock price changed, your net worth will increase or decrease. You will gain or lose Pubby Cash only at the moment the stocks are sold. The recommendation is if you see the price of the stock you are holding decreases at a moment, keep holding it, unless you urgently need Pubby Cash at that moment. Be confident in the US economy! The overall trend of investment should make you gain money in the long run. A side note: Without Pubby Cash at a whole number multiple of one share price will not forbid you from buying that stock. Feel free to use a fractional number, no matter how small it is. You also don't need to invest all your Pubby Cash into the same company. You can split your Pubby Cash into multiple investments, which simulates S&P500 and can greatly lowers your investment risks. Have fun in the GoPubby Stock Market! ...  Read more

1 ... 20 21 22 ... 32

Daily Deals


MECHANICSBURG WEATHER