I think I've got a hold of this programming thing; the logic, thought process, the intense planning. So that is why I'll be moving on to a more difficult language to try and expand my horizons. That's right, the infamous beginner code killer - C++.
I learned much more about programs and games and that you don't always have to build everything from the ground up. There are many pieces of software out there that will give you the tools to build what you want and the best part, a lot of them are free. Not just free to use, but also free to commercially release. Here's a list of many game engines(payed, and free) that could get you started now. Game Engines
But how will I start?
I've begun to take lessons on learncpp.com and found a series of tutorials from "Lazy Foo' Productions" on how to use SDL to create graphics for applications.
The parameters of the challenge are unclear so far but I will try to come back with a basic game made using Visual Studio and SDL.
Later.
The Naive Coder
Saturday, July 20, 2013
Thursday, July 18, 2013
Python GUI (Graphics User Interface) for Prime Finder Program
I've wondered, how the heck do I get something on screen!? Pretty much every program I've worked with used text in the Python Shell or command line. And so, I found this -- Python GUI
There are many Python GUIs that will help you get your program up and running in a window, and I chose Tkinter.
Why?
Well, it comes with Python and it seemed like the simplest one to start out learning.
So here is the code for making my Prime Finder function work in a window:
And the result should look something like this:
Here is the copy pasta:
import sys
from tkinter import *
def Prime_finder():
mtext = ment.get()
if mtext < 2:
return False
else:
count = 0
for i in range(1, mtext + 1):
if mtext % i == 0:
count += 1
if count == 2:
l = Label(mGui, text="True").pack()
else:
l = Label(mGui, text="False").pack()
return
mGui = Tk()
ment = IntVar()
mGui.geometry("450x500+400+200")
mGui.title("$$$$Prime Number Finder$$$$")
mlabel = Label(mGui, text="Enter Your Prime Number").pack()
mbutton = Button(mGui, text = "Check", command = Prime_finder).pack()
mEntry = Entry(mGui, textvariable=ment).pack()
There are many Python GUIs that will help you get your program up and running in a window, and I chose Tkinter.
Why?
Well, it comes with Python and it seemed like the simplest one to start out learning.
So here is the code for making my Prime Finder function work in a window:
And the result should look something like this:
Here is the copy pasta:
import sys
from tkinter import *
def Prime_finder():
mtext = ment.get()
if mtext < 2:
return False
else:
count = 0
for i in range(1, mtext + 1):
if mtext % i == 0:
count += 1
if count == 2:
l = Label(mGui, text="True").pack()
else:
l = Label(mGui, text="False").pack()
return
mGui = Tk()
ment = IntVar()
mGui.geometry("450x500+400+200")
mGui.title("$$$$Prime Number Finder$$$$")
mlabel = Label(mGui, text="Enter Your Prime Number").pack()
mbutton = Button(mGui, text = "Check", command = Prime_finder).pack()
mEntry = Entry(mGui, textvariable=ment).pack()
I learned this from a youtube user: TheReimber
Here is the video that made my little program possible. Enjoy!
Tuesday, May 28, 2013
Beginner Challenge #1: Python algorithm for prime numbers ~~Completed
With procrastination against me, I managed to finish this task. As simple as this is, I'm pretty proud of it. On the bottom you can see I am testing my Prime_finder function with a really large prime number (31,789,553) and the results came out as True.
How I completed it.
The one special property of prime numbers is that it's a number that is only evenly divisible by itself and the number 1. In other words it has 2 divisors
In the code I set up firstly that if the number handed was less than 2 then there's no way for it to be a prime number:
if x < 2:
return False
Then in the second part, the else statement, I set up the code so that it checks every number below x if it is divisible by that number. AND if it was, then I would count that.
for i in range(1, x + 1):
if x % i == 0:
count += 1
Lastly, at the end of the code, it checks to see how many counts there are for x. If x has more than 2 divisors, then it's not a prime number and returns False.
Could I have done this better?
Maybe.
This was a brute force attempt, and you'll notice that if you run really large numbers through this it can take up to half a minute which is quite some time in the mind of a programmer.
Thanks for reading, until next time!
Monday, May 27, 2013
Beginner Programmer Challenge #1: Pyhton algorithm for prime numbers
An algorithm, in other words, is just a step by step procedure for producing a wanted outcome. This challenge is about finding a step by step procedure for a program to determine if a given number input is prime or not.
Now, I could search for the answer, but what fun would that be? I plan on finishing this within the day. It can't be too difficult...can it?
Now, I could search for the answer, but what fun would that be? I plan on finishing this within the day. It can't be too difficult...can it?
Sunday, May 26, 2013
The Code I Use: Python (mostly), JavaScript, HTML, CSS
The challenges I will be giving myself will probably be in Python most of the time, but I will also try to add a little more variety at times.
Just to give a background on myself, I am by no means very good so expect these first posts to take on very simple tasks. I've been practicing learning to code for about 3 months now (I started in February).
Motivational quote of the night: Let the challenges, and my road to success begin!
Just to give a background on myself, I am by no means very good so expect these first posts to take on very simple tasks. I've been practicing learning to code for about 3 months now (I started in February).
Motivational quote of the night: Let the challenges, and my road to success begin!
-Helen Hayes
How to Motivate yourself to code more.
Like any other chap in dire need of motivation, I googled "How to motivate yourself". The first thing I found was some article on about.com listing it's theories. I have my doubts on these methods working, but that may just be my cynical side speaking. Anyhoo.
My two main methods I'll be keeping are the Incentive and Drive theories.
My two main methods I'll be keeping are the Incentive and Drive theories.
- The incentive theory states that people will be motivated because of external rewards.
I hereby proclaim that for every successful challenge I finish I will....I will...I don't know yet but surely it will be good.
- The drive theory states that people are motivated to take actions in order to reduce the internal tension that is caused by unmet needs.
I've always hated leaving things unfinished so by making this blog public I would become even more ashamed. If I am lacking in consistency, feel free to heckle in the comments!
First Day, The beginning
Serving as a reminder
I've always wanted to learn to code something more advanced, but the motivation...it is lacking. This blog will serve as a reminder and self promise to keep practicing reading, writing, pondering code. I don't know what content I will post here, but for now it will be challenges I set for myself, its progress, and in the end I will publish my hard earned code here, for free.
Subscribe to:
Posts (Atom)