Member

[email protected]

Total likes received: 98 | Pubby Cash: 932


Articles Liked by Me: 87

How to Use the Random Method in Python

Categories: Tech | Pubby Cash Received:  0

The random method in Python is a very useful tool in Python because it has the power to select a random value. In this article, I will try my best to explain how to use the random method. The first thing that you need to know is that you have to import random first to access it. import random I will now provide an example of how to use the random method. Lets say that we want our program to generate a random number from one through five. This is how we can use the random method to do it. import random numbers = [1, 2, 3, 4, 5] print(random.choice(numbers)) This code is saying that numbers is equal to 1, 2, 3, 4, and 5. We are then printing a random number that is in the numbers variable. The output of this program could be 1, 2, 3, 4, or 5. This is because we are choosing a random number. After reading this article, you should have a better understanding about how to use the random method....  Read more

VirtualBox

Categories: General, Tech | Pubby Cash Received:  0

You've known about a working framework, yet have you known about running numerous frameworks in a single machine? Although running Windows on a Mac sounds peculiar, it would all be able to be cultivated with a virtual machine. So what's a virtual machine you inquire? A virtual machine (or often abbreviated VM) is a working framework or application condition that is installed on software, which imitates dedicated hardware. The user will have a similar experience on a virtual machine as they would have on committed equipment. The best part is that there are many free choices for virtual machines out there, with one being VirtualBox. VirtualBox is extremely simple to utilize and set up. Download from their site and make another virtual machine without any preparation. Presently, what's the purpose of running another PC on your PC? VirtualBox empowers you to run more than each OS in turn. Along these lines, you can run software composed for one OS on another, for example, Windows programming on Linux or a Mac, without rebooting to utilize it. Since you can design what sorts of virtual equipment ought to be introduced to each such OS, you can introduce an old OS, for example, DOS or OS/2 regardless of whether your genuine PC's equipment is not, at this point bolstered by that OS. Additionally, once installed, a virtual machine and its virtual hard disks can be considered a container that can be arbitrarily frozen, woken up, copied, backed up, and transported between hosts. It is likewise conceivable to imitate a cell phone with VirtualBox utilizing Nox App Player. Nox will run with VirtualBox and you'll feel like you're utilizing a tablet in your PC. This can be exceptionally valuable, particularly with regards to gaming. Maybe a game you need is just accessible for cell phones yet you don't care for tapping a screen each an ideal opportunity to play it, well Nox App Player is the solution! With VirtualBox, you can do numerous things! Just keep in mind that if your computer has low specs, it might delay for certain periods....  Read more

How to Use an If, Elif, and Else Statement in Python

Categories: Tech | Pubby Cash Received:  0

Do you know how to use an if statement in Python? If you do not know how you should read this article because it will teach you how. First of all, the if statement is written using the if keyword in Python. Python also supports the logical conditions of mathematics. Here is what an if statement can look like. a = 1 b = 2 if a < b:     print("a is less than b.") The code above basically means that a is equal to 1 and b is equal to 2. The if statement is saying that a is less than b. Since 1 is less than 2, this would print a is less than b.. You must also make sure that the print statement is indented after the if statement because Python relies on indentation. If you do not indent, an error will appear. There is also an elif statement. This statement means that if the previous conditions were not true, then try this condition. Here is what an elif statement could look like. a = 3 b = 3 if b > a:     print("b is greater than a") elif a == b:     print("a and b are equal") The code above means that if b is greater than a, print b is greater than a. However, b is not greater than a. Since it is not, it moves on to the elif statement. The elif is saying that if a and be are equal, print a and b are equal. Since a and b are equal, this would print a and b are equal. Finally, there is the else statement. The else statement means that it catches anything which isn't caught by the preceding conditions. Here is what an else statement could look like a = 2 b = 1 if b > a:     print("b is greater than a") elif a == b:     print("a and b are equal") else:     print("a is greater than b" The code above means that if b is greater than a, print b is greater than a. However, it is not, so it then sees if a and b are equal. Since a and b are not equal, the else statement sees if a is greater than b. Since 2 is greater than 1, this would print a is greater than b. Hopefully, after reading this article, you have a good idea of how the if, elif, and the else statement work....  Read more

How to Turn Some Data in a Dictionary Into a CSV File Using Python

Categories: Tech | Pubby Cash Received:  0

Do you know how to turn some data in a dictionary into a CSV File Using Python? If you do not know how here is a way to do it. You first need to import CSV. If you don't know what CSV stands for, it stands for a comma-separated values file. After importing CSV, you need to import datetime from datetime. The datetime means what the time and the date are. Here is an example. import csv from datetime import datetime After you do that, you have to open your data. You can do this using the with open method. After opening it, you have to use the read method and the eval method. Here is an example. f_path = 'stocks.txt' with open(f_path, 'r') as f:     content = f.read()     stocks = eval(content) Then, you can make an empty dictionary using curly brackets. After making a dictionary, use a for loop. Make sure you use k because k stands for key and you want to use the key. Here is an example. stocks_price = {} for k in stocks:     stocks_price[k]=stocks[k][1] stocks_price['Time'] = datetime.now() After doing that, you can use another for loop to append it to your key. The append method is used to add things. fnames = ['Time'] for k in stocks:     fnames.append(k) Next, you need to open a CSV file as a CSV file and use set the mode equal to w. The w stands for write. Then use the DictWriter method. This method can map Python dictionaries into CSV rows. Use the writeheader method after that. This method writes the headers to the CSV file. Here is an example. with open('stocks_history.csv', mode='w') as csv_file:     writer = csv.DictWriter(csv_file, fieldnames=fnames)     writer.writeheader() After that, use the now method. This method returns the current local date and time. The open your CSV file and make sure you set the mode to a+. The a+ means that you can open for reading and appending (writing at end of file). Finally, use the DictWriter and the writerow method. The writerow method writes a row of data into the specified file. Here is an example. stocks_price['Time'] = datetime.now() with open('stocks_history.csv', mode='a+') as f:     csv_writer = csv.DictWriter(f, fieldnames=fnames)     csv_writer.writerow(stocks_price) If you did all of the above correctly, you should have turned some data in a dictionary into a CSV file....  Read more

How to Embed Online Games in Your Articles

Categories: General, Tech, Gaming | Pubby Cash Received:  10

Here's how to do it. Simply paste the iframe into the content box and you're good to go. Here is an example. <iframe src="https://scratch.mit.edu/projects/408082131/embed" style="width: 100%; height: 100%; position: relative;" allowtransparency="true" frameborder="0" scrolling="no" allowfullscreen></iframe> ...  Read more

1 ... 6 7 8 ... 18

Daily Deals


MECHANICSBURG WEATHER