python

Automate the Boring Stuff with Python: Practical Programming for Total Beginners by super Python expert Al Sweigart is a pretty thick intermedia to somewhat advanced level programming book. It covers how Python works, so someone familiar with programming languages can get up to speed. Then, the book tackles a number of key important tasks one may use a computer for. This includes working with Regular Expressions, file reading and writing, web scraping, interacting with Excel spreadsheets and PDF files, scheduling things, working with email, manipulating images, and messing around with the…
Your objective is to learn Python programming. Everybody has to learn Python. You are looking for a book that will make that easier for you. One possibility, one that I'll recommend for most people in this situation, is Python Crash Course: A Hands-On, Project-Based Introduction to Programming. To cut to the chase, there are two reasons I recommend this book. First, the specific programming projects used in the book are a good match for most people, because they are bare bones (but highly developed) exemplars that are fairly adaptable and together cover a wide range of applications and…
There is really no better time to get a Raspberry Pi. The new Raspberry Pi 3 has features that make it much more useful and fun, including more speed, built in bluetooth, and built in wifi. The Raspberry Pi is a small computer that, out of the box, lacks storage drive or device, a monitor, a screen, or a mouse, but is otherwise a fully functional computer that can run a normal operating system. It costs very little, so if you happen to have a TV or monitor that can use a component or HDMI hookup, a keyboard, a mouse, and an appropriate microSD card, then you have a computer for $39.99. If…
Minecraft is a gaming world. Or, if you like, a "sandbox." This is a three dimensional world in which characters do things, all sorts of things. The context for the world of Minecraft is very open ended. The player builds things, moves things, gets things, does things, in a way that makes any one gamer's game potentially very different from any other gamer's game. You can buy Minecraft in various forms such as an XBox 360 version. It comes in Lego form (for example, this), and you can get a Minecraft cloud server version at Minecraft.net. If you install Minecraft from Minecraft.net (about…
Day 4 of the meeting turned out to be pretty exciting for a comparative physiologist as well. The first session that I went to was called "RNASEQ approaches to understanding extreme physiological adaptations." Considering the Comparative and Evolutionary Physiology section business and dinner meeting was the night before, I was impressed at my ability to make it to an 8:00am session the following morning. The first seminar from Dr. Brooke C Harrison  (Univ. Colorado, Boulder) was on "Extreme cardiac growth and metabolism in the Burmese python after feeding." He spoke about how the cells of…
An river otter was captured on camera taking on an juvenile alligator...and winning. The battle took place at the Lake Woodruff National Wildlife Refuge in Florida in 2011. More images can be seen on their Facebook page where the images were recently posted, impressive! According to National Geographic, the normal diet of a river otter consists of birds, small rodents, frogs, turtles, crabs, and fish. Let's just add juvenile alligators to the list now. Photo from U.S. FISH AND WILDLIFE SERVICE/FACEBOOK   Perhaps equally impressive is this olive python that was seen strangling then…
My first computer language was PL/1, but soon after I learned, among other languages, Basic, and I really liked Basic and I still do. Basic is linear, and I think in linear constructs when I do any kind of computer program. This is probably, in part, because user interfaces are the last thing I want to deal with. I want a series of numbers to be treated in a certain way, or a set of formulas to generate a database. The most non-linear I tend to get is multidimensional arrays, and that's still linear. Python is potentially, and in practice, very different, and is essentially used as an…
Actually, it should be called Happy "Magnitude of the local Earth gravitational field" day. You know, 9.8 N/kg on September 8 (9/8). Get it? Well, the idea was for the physics students and faculty to build some stuff to do outside - projectile motion type stuff. Well, we had the idea a while ago and then kind of forgot about it. In order to just get something done, I set up the "shoot the falling target" demo. (previously known as shoot the monkey). Here is a quick video demo (seriously - first take too). What is going on here and what does this have to do with g? Well, it doesn't…
You can call it football if it makes you happy. Anyway, this is a popular story going around. The physics of the magic curving soccer kick. Here are two ends of the spectrum. First, there is the lower, easier to consume version from io9.com Physics forced to come up with whole new equation to explain "impossible" soccer kick I will summarize this article for you: "Have you seen these crazy soccer kicks where the ball curves? It happens because the ball spins and physics. Here is a video" Oh, and they have a diagram - which doesn't seem to come from the original paper and they also have…
Yes, I love python. However, I am no expert. Most of the stuff I write in python is dirty and ugly code. Sometimes I figure out new things (things that programmers already know) and sometimes I forget these things. So, here are a few tips and tricks that I use from time to time. Really, I am writing this for future Rhett when he does a google search for "how do you save data to a file in python". Saving data to a file Suppose I am modeling a basketball falling through the air. I want to plot this data, so I save position and time data in lists. For example: Here is the info from scipy…
Let me start with the video. Here is a guy flying a plane in a barrel roll and pouring some tea at the same time. Talk about multitasking. How can he pour upside down? Well, there are two ways to look at this. First, I can look at this in the frame of the plane. For this case, I can invoke the fake force - centrifugal force. Oh yes, I am going to do it. You probably remember all your physics instructors warning you to never ever do this. Well, they say that because they are afraid you will do something bad with it. Here, I will only use the centrifugal force for good. What is the…
I can't let it go. There is more here to explore. First, I can't believe that I looked at braking and then turning but not turning then braking. And what about braking while turning? I will model braking and then turning - but it won't stop here. Consider a few motions. I could turn and then brake (which I am looking in this post). Another option would be to brake and then turn. I already showed that this takes a longer distance than just stopping. Braking and then turning in general won't work. Suppose I brake and slow down to a certain speed. Now I am a certain distance away from…
I have seen several videos similar to this. Real? Fake? How many tries did this take? Let the analysis begin. Before I do any analysis, let me state that I think this is not fake. I do not know that for sure, just my first guess. How would I tell if it is real or fake? This is tricky. I can't really get a good trajectory of the ball to make some measurements on it because of the camera angle (next time people, make sure you set the camera up perpendicular to the plane of motion and far enough away to avoid perspective problems - thanks!) Really, the best I can do is to look at the…
Here is part of a picture some of my friends posted from a recent high school reunion. It may be hard to tell, but this is part of a picture of 7 females all wearing black. I just wanted to show you that they were indeed wearing black without giving away anymore details. If you are one of these people and you want your whole picture included, I will be happy to make that change and include your face. Anyway, my first comment was: "Wow, everyone is wearing black. Was this a planned event or was black part of the dress code?" The response was that it was just pure chance that all the women…
(alternate title: how to make pretty graphs in vpython) I am happy. Finally, I can use the visual module in python (vPython.org) and plotting with Matplotlib. Maybe this isn't such a big deal for many of you, but for me, it never worked until now. In the past, I blogged about plotting in vpython vs. matplotlib. My conclusion was that it was easier in vpython, but prettier in matplotlib. So, why not just use matplotlib? There are a couple of things that make vypthon very attractive. Vectors. Vpython has a built in vector class (or function - I don't know what I am talking about). There…
In my last zombie post, I looked at a human moving in a circle to avoid a zombie (if they are stuck in a room). What if I build a zombie evading robot that always moves perpendicular to the path of the zombie? Would this work? This shouldn't be too difficult to model. I can use my existing model for the zombie (where there is a force towards the human and a drag force). For the right-turning-robot, I will also have a drag force and a "driving" force. How do I find the direction of the driving force for the robot? Here is a diagram. This Fdrive force will really be the frictional force…
Title: Chased by zombies When I heard word about the ScienceBlogs Zombie Day, I knew I wanted to participate with a post - but I had no idea what to do. My first thought was to somehow talk about living off the electric grid in the case of a zombipocolypse - you know, like how big of a solar panel would you need? But you know what? Physics is difficult - but modeling is easy. How about I model something? How about a model for the motion of a zombie horde? This will be great. Zombie motion model What do I want in my model? What are the constraints? What real-life situations can I use to…
So suppose you saw something that looked like this: This is a ball shot out of a shooter device. Well, it is a vypthon animation of a ball. What would you do if you came to see this video? If I had not made it, I would say it is an unrealistic video. It does not agree with my basic model of how things move after being thrown or shot or whatever. Interestingly (but unrelated) there was a set of physics questions that showed different possible paths of a thrown ball. The path representing the motion above was a common choice. Like I said, I made that animation. Here is another one. In…
While I am still fresh on the Space Jump topic, let me take it to the extreme. Star Trek extreme. SPOILER ALERT But really, is this a spoiler alert if it is from the trailer of a movie that has been out forever? Of course, I talking about the latest Star Trek movie where three guys jump out of a shuttle and into the atmosphere. So, in light of the Red Bull Stratos jump, how would this jump compare? First, my assumptions: This Star Trek jump is on the planet Vulcan. I am going to assume this is just like Earth in terms of gravity and density of air. The jumpers in Star Trek have on stuff…
A new video from the Red Bull Stratos Jump guys came out. Here it is: This reminds me of an unanswered question about the Stratos jump that I didn't address on my last post on this topic. Commenter Long Drop asked about how much Felix would heat up as he falls from 120,000 feet. This is a great question. The first, off the bat answer is that he won't heat up too much. Why do I say this? Well, when Joe Kittinger jumped from over 100,000 feet and didn't melt. Still, this is a great thing to calculate. How do you calculate something like this? I will look at this in terms of energy. For…