<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-9066631589719297739</id><updated>2026-03-04T00:31:42.015-08:00</updated><category term="Python"/><category term="beginning programming"/><category term="DirectX"/><category term="computer logic"/><category term="computer program design"/><category term="programming"/><category term="computer science"/><category term="float"/><category term="integer"/><category term="visual studio express"/><category term="while"/><category term="Game Programming"/><category term="beginner"/><category term="break"/><category term="counter"/><category term="for"/><category term="game"/><category term="int"/><category term="operand"/><category term="operator"/><category term="prime"/><category term="program design"/><category term="programming logic"/><category term="string"/><category term="variables"/><category term="C"/><category term="C#"/><category term="C++"/><category term="ID3D10Device"/><category term="IDE"/><category term="IDXGISwapChain"/><category term="Java"/><category term="Setting up DirectX"/><category term="Win32"/><category term="android"/><category term="assignment operator"/><category term="camel case"/><category term="comparison operator"/><category term="computer"/><category term="computers"/><category term="convert"/><category term="define"/><category term="design life cycle"/><category term="development"/><category term="docstring"/><category term="eclipse"/><category term="floating point"/><category term="flowchart"/><category term="functions"/><category term="if"/><category term="if then"/><category term="input"/><category term="integrated development envioronment"/><category term="learn"/><category term="legal variable names"/><category term="lists"/><category term="logic"/><category term="loop"/><category term="loops"/><category term="modulo"/><category term="naming"/><category term="number"/><category term="order of operations"/><category term="output"/><category term="planning"/><category term="program"/><category term="programing"/><category term="programs"/><category term="psuedocode"/><category term="random"/><category term="repetition"/><category term="selection"/><category term="sequence"/><category term="software"/><category term="str"/><category term="structured programming"/><category term="then"/><category term="types"/><title type='text'>Geek Spot 101</title><subtitle type='html'>Computer Science, Games...etc</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://geekspot-101.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9066631589719297739/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://geekspot-101.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Geek Spot 101</name><uri>http://www.blogger.com/profile/09401800505792806961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>24</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-9066631589719297739.post-158526362435810925</id><published>2011-02-06T09:02:00.001-08:00</published><updated>2011-02-06T09:02:48.783-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="DirectX"/><category scheme="http://www.blogger.com/atom/ns#" term="IDXGISwapChain"/><title type='text'>The IDXGISwapChain</title><content type='html'>IDXGISwapChain *g_swapChain = NULL;&lt;br /&gt;
&lt;br /&gt;
Since we will be  creating them together lets explain the swap chain. A swap chain is one  or more back buffers used to make rendering more smooth. While the  device renders one image on your screen the swap chain buffers another  image in wait which can be swapped out with the last image. When you  think that your game has to process AI, movement, player and enemy  health, and more as well as graphics that update 60 times a second you  can see why processing the screen image early and often can be useful.  It is recommended to have at least 2 buffers.</content><link rel='replies' type='application/atom+xml' href='http://geekspot-101.blogspot.com/feeds/158526362435810925/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://geekspot-101.blogspot.com/2011/02/idxgiswapchain.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9066631589719297739/posts/default/158526362435810925'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9066631589719297739/posts/default/158526362435810925'/><link rel='alternate' type='text/html' href='http://geekspot-101.blogspot.com/2011/02/idxgiswapchain.html' title='The IDXGISwapChain'/><author><name>Geek Spot 101</name><uri>http://www.blogger.com/profile/09401800505792806961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9066631589719297739.post-4883929986975368095</id><published>2011-02-06T09:01:00.000-08:00</published><updated>2011-02-06T09:01:56.340-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="DirectX"/><category scheme="http://www.blogger.com/atom/ns#" term="ID3D10Device"/><title type='text'>The ID3D10Device</title><content type='html'>&amp;nbsp;ID3D10Device *g_d3dDevice = NULL&lt;br /&gt;
&lt;br /&gt;
Declares an ID3D10Device pointer as NULL. Later when we initialize D3D10 we will actually create it with the function &lt;span style=&quot;font-family: inherit;&quot;&gt;D3D10CreateDeviceAndSwapChain()&lt;/span&gt;, but for now this is sufficient. But what exactly is the ID3D10Device? Our d3dDevice will be the access point to the video hardware. All of the methods involved in drawing to the screen and accessing VRAM are handled through this device.</content><link rel='replies' type='application/atom+xml' href='http://geekspot-101.blogspot.com/feeds/4883929986975368095/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://geekspot-101.blogspot.com/2011/02/id3d10device-and-swapchain.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9066631589719297739/posts/default/4883929986975368095'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9066631589719297739/posts/default/4883929986975368095'/><link rel='alternate' type='text/html' href='http://geekspot-101.blogspot.com/2011/02/id3d10device-and-swapchain.html' title='The ID3D10Device'/><author><name>Geek Spot 101</name><uri>http://www.blogger.com/profile/09401800505792806961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9066631589719297739.post-7760119848211269710</id><published>2011-02-06T08:35:00.000-08:00</published><updated>2011-02-12T07:30:26.892-08:00</updated><title type='text'>DirectX 10 Programming Tutorial 1.2</title><content type='html'>/******************************************************************************&lt;br /&gt;
Our first program with DirectX!&amp;nbsp; Let&#39;s jump straight into code and then explain what is going on as we go.&lt;br /&gt;
If you are just joining me you should start &lt;a href=&quot;http://geekspot-101.blogspot.com/2011/02/first-win32-application.html&quot;&gt;here&lt;/a&gt; to get an idea of basic Win32 applications as this code just fits on top of that code.&lt;br /&gt;
&lt;div style=&quot;font-family: inherit;&quot;&gt;******************************************************************************/&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;#include &amp;lt;D3D10.h&amp;gt;&lt;/div&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;#include &amp;lt;D3DX10.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;//D3D Global variables&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;ID3D10Device *g_d3dDevice = NULL;&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;IDXGISwapChain *g_swapChain = NULL;&lt;/div&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;ID3D10RenderTargetView *g_renderTargetView = NULL;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;//Function Declarations&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;bool Initialize(HWND hWnd);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;void Render();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;void ResizeWindow(int width, int height);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;void ShutDown();&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: inherit;&quot;&gt;/***************************************************************************&lt;/div&gt;&lt;div style=&quot;font-family: inherit;&quot;&gt;To save space I&#39;ve decided to put the definition of each of these on a separate page so click on each new type to go to a description of what each is and why we need it. Now, we have declared our &lt;a href=&quot;http://geekspot-101.blogspot.com/2011/02/id3d10device-and-swapchain.html&quot;&gt;device&lt;/a&gt;, &lt;a href=&quot;http://geekspot-101.blogspot.com/2011/02/idxgiswapchain.html&quot;&gt;swap chain&lt;/a&gt; and render target view and have functions to intialize, render, resize and shutdown. I&#39;ll start by defining these functions and then we&#39;ll go back through our Win32 app code to put them to use.&lt;/div&gt;&lt;div style=&quot;font-family: inherit;&quot;&gt;****************************************************************************/&lt;/div&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;bool Initialize(HWND hWnd)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; DXGI_SWAP_CHAIN_DESC scDesc;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;  &amp;nbsp; ZeroMemory(&amp;amp;scDesc, sizeof(scDesc));&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //We need to define and create the swap chain&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; scDesc.BufferCount = 2;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; scDesc.BufferDesc.Width = WINDOW_WIDTH;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; scDesc.BufferDesc.Height = WINDOW_HEIGHT;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; scDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; scDesc.BufferDesc.RefreshRate.Numerator = 60;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; scDesc.BufferDesc.RefreshRate.Denominator = 1;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; scDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; scDesc.OutputWindow = hWnd;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; scDesc.SampleDesc.Count = 1;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; scDesc.SampleDesc.Quality = 0;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; scDesc.Windowed = TRUE;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; //Setup the debug utility for testing&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned int flags = 0;&lt;br /&gt;
&lt;br /&gt;
#ifdef _DEBUG&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; flags |= D3D10_CREATE_DEVICE_DEBUG;&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; //Create a loop to test for availability of Reference or Hardware&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; //Driver type&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; D3D10_DRIVER_TYPE driverType = D3D10_DRIVER_TYPE_NULL;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; D3D10_DRIVER_TYPE driverTypes[] =&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; D3D10_DRIVER_TYPE_HARDWARE,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; D3D10_DRIVER_TYPE_REFERENCE,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; };&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; HRESULT hr = NULL;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned int numDriverTypes = sizeof(driverTypes) / sizeof(driverTypes[0]);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; for (unsigned int i = 0; i &amp;lt; numDriverTypes; i++)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; driverType = driverTypes[i];&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; hr = D3D10CreateDeviceAndSwapChain(NULL,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; driverType,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; NULL,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; flags,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; D3D10_SDK_VERSION,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;scDesc,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;g_swapChain,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;g_d3dDevice);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if(SUCCEEDED(hr))&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; break;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if(FAILED(hr))&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return false;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ID3D10Texture2D *buffer = NULL;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; hr = g_swapChain-&amp;gt;GetBuffer(0, __uuidof(ID3D10Texture2D), (LPVOID*)&amp;amp;buffer);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if(FAILED(hr))&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return false;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; //Create the render target view&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; hr = g_d3dDevice-&amp;gt;CreateRenderTargetView(buffer, NULL, &amp;amp;g_renderTargetView);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; buffer-&amp;gt;Release();&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if(FAILED(hr))&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return false;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; //Set the render target&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; g_d3dDevice-&amp;gt;OMSetRenderTargets(1, &amp;amp;g_renderTargetView, NULL);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ResizeWindow(WINDOW_WIDTH, WINDOW_HEIGHT);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; return true;&lt;br /&gt;
}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;void ResizeWindow(int width, int height)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;if(g_d3dDevice == NULL)&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;return;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;D3D10_VIEWPORT vp;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;vp.Width = width;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;vp.Height = height;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;vp.MaxDepth = 1.0f;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;vp.MinDepth = 0.0f;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;vp.TopLeftX = 0;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;vp.TopLeftY = 0;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;g_d3dDevice-&amp;gt;RSSetViewports(1, &amp;amp;vp);&lt;br /&gt;
}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;void Render()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;float col[4] = { 1, 0, 0, 1 };&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;g_d3dDevice-&amp;gt;ClearRenderTargetView(g_renderTargetView, col);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;g_swapChain-&amp;gt;Present( 0, 0 );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void ShutDown()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;// Release memory&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;if(g_d3dDevice) g_d3dDevice-&amp;gt;ClearState();&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;if(g_swapChain) g_swapChain-&amp;gt;Release();&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;if(g_renderTargetView) g_renderTargetView-&amp;gt;Release();&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;if(g_d3dDevice) g_d3dDevice-&amp;gt;Release();&lt;br /&gt;
}&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: inherit;&quot;&gt;/***************************************************************************&lt;/div&gt;The  Initialize() function is the longest function so far and it just gets  us set up so we can do the fun stuff. Again it&#39;s description is posted  separately, as well as the resize, render, and shutdown functions. Now we should put our code to use in our window.&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
****************************************************************************/&lt;br /&gt;
&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;//To WndProc() we add:&lt;br /&gt;
int height,width;&lt;br /&gt;
&lt;br /&gt;
//In WM_DESTROY... break;&lt;br /&gt;
case WM_SIZE:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; height = HIWORD(lParam);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; width = LOWORD(lParam);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if(height == 0)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; height = 1;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ResizeWindow(width, height);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
//In WinMain()&lt;br /&gt;
//Replace old message loop from while(msg.message != WM_QUIT)&lt;br /&gt;
//to DispatchMessage(&amp;amp;msg) } } with:&lt;br /&gt;
if(Initialize(hWnd))&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; while(true)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if(PeekMessage(&amp;amp;msg, 0, 0, 0, PM_REMOVE))&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if(msg.message == WM_QUIT) break;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; TranslateMessage(&amp;amp;msg);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; DispatchMessage(&amp;amp;msg);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Render();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
}&lt;/div&gt;&lt;br /&gt;
/***************************************************************************&lt;br /&gt;
And you&#39;re done! When you compile this code you should get a blank window filled with red. You can change this color by changing the values for &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;col&lt;/span&gt; in Render() realizing that the values are Red, Green, Blue, and Alpha. Alpha is the opacity and values range from 0 being none to 1 maximum See the &lt;a href=&quot;http://en.wikipedia.org/wiki/RGBA_color_space&quot;&gt;wiki article on RGBA&lt;/a&gt; for more information.&lt;br /&gt;
***************************************************************************/&lt;br /&gt;
&lt;a href=&quot;http://geekspot-101.blogspot.com/2011/02/directx-10-sdk.html&quot;&gt;DirectX 10 Programming Tutorial 1.1 &lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://geekspot-101.blogspot.com/feeds/7760119848211269710/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://geekspot-101.blogspot.com/2011/02/directx-10-programming-tutorial-12.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9066631589719297739/posts/default/7760119848211269710'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9066631589719297739/posts/default/7760119848211269710'/><link rel='alternate' type='text/html' href='http://geekspot-101.blogspot.com/2011/02/directx-10-programming-tutorial-12.html' title='DirectX 10 Programming Tutorial 1.2'/><author><name>Geek Spot 101</name><uri>http://www.blogger.com/profile/09401800505792806961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9066631589719297739.post-8892476635930572614</id><published>2011-02-05T18:32:00.000-08:00</published><updated>2011-02-05T20:41:00.840-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="DirectX"/><category scheme="http://www.blogger.com/atom/ns#" term="Game Programming"/><category scheme="http://www.blogger.com/atom/ns#" term="Setting up DirectX"/><title type='text'>DirectX 10 ProgrammingTutorial 1.1</title><content type='html'>DirectX is a collection of APIs(Application Programming Interfaces)  that  give you advanced control of video, sound,&amp;nbsp; and input on the Windows  system. ***NOTE*** DirectX 10 is only available for Windows versions  Vista and later. The hardest part of starting with DirectX so far for me  has been, well, starting with DirectX. I&#39;ll get the code in word for  word from some book or tutorial and get a whole slew of errors. I kept  thinking it was poor authoring or something but I realized I just did  not know how to set DirectX up properly for my IDE.&amp;nbsp; To start out you  should go &lt;a href=&quot;http://www.microsoft.com/downloads/en/details.aspx?displaylang=en&amp;amp;FamilyID=3021d52b-514e-41d3-ad02-438a3ba730ba&quot;&gt;here  to download the DirectX10 SDK.&amp;nbsp; &lt;/a&gt;Also, so that you can create shaders which will be needed as we progress through DX, I recommend downloading &lt;a href=&quot;http://developer.nvidia.com/object/fx_composer_home.html&quot;&gt;NVIDIA&#39;s FX Composer 2.5&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
There are a few ways we could start but I like the way Allen Sharrod started in &lt;a href=&quot;http://www.amazon.com/Ultimate-Programming-DirectX-Allen-Sherrod/dp/1584505591/ref=sr_1_1?ie=UTF8&amp;amp;s=books&amp;amp;qid=1296962985&amp;amp;sr=8-1&quot;&gt;Ultimate Game Programming with DirectX, Second Edition &lt;/a&gt;so that is how I will start. But first, let&#39;s get VC++ set up for DirectX. If you have your skeleton file created from the last tutorial you should now:&lt;br /&gt;
&lt;br /&gt;
1. Go to Project-&amp;gt;Properties-&amp;gt;Configuration Properties-&amp;gt;VC++ Directories-&amp;gt;Include Directories.&lt;br /&gt;
2. Select the down arrow and then edit.&lt;br /&gt;
3. Click the folder Icon. Click the ... button.&lt;br /&gt;
4. Navigate to the folder you installed the DirectX 10 SDK to.&lt;br /&gt;
5. Navigate into the folder to the Include folder.&lt;br /&gt;
6. Click Select Folder click OK.&lt;br /&gt;
7. Repeat steps 1-6 for the Library Directories navigating to the lib/x86 folder.&lt;br /&gt;
8. Go to Project-&amp;gt;Properties-&amp;gt;Configuration Properties-&amp;gt;Linker-&amp;gt;Input&lt;br /&gt;
9. Select Additional Dependencies&lt;br /&gt;
10. Select the down arrow, then edit&lt;br /&gt;
11. Add &quot;d3d10.lib; d3dx10.lib&quot; not including the quotes.&lt;br /&gt;
12. Accept the changes and you are done. You should now be able to start working on our first DirectX Program!</content><link rel='replies' type='application/atom+xml' href='http://geekspot-101.blogspot.com/feeds/8892476635930572614/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://geekspot-101.blogspot.com/2011/02/directx-10-sdk.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9066631589719297739/posts/default/8892476635930572614'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9066631589719297739/posts/default/8892476635930572614'/><link rel='alternate' type='text/html' href='http://geekspot-101.blogspot.com/2011/02/directx-10-sdk.html' title='DirectX 10 ProgrammingTutorial 1.1'/><author><name>Geek Spot 101</name><uri>http://www.blogger.com/profile/09401800505792806961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9066631589719297739.post-4970156040380514998</id><published>2011-02-05T17:47:00.000-08:00</published><updated>2011-02-06T08:21:03.395-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="visual studio express"/><category scheme="http://www.blogger.com/atom/ns#" term="Win32"/><title type='text'>First Win32 application</title><content type='html'>/****NOTE****&lt;br /&gt;
The following code has been borrowed from many sources which I will try to note as I go through this. This blog is to benefit my learning and if it helps others at the same time, all the better. Each author has their own way they like to code and I have taken things from each which makes the most sense to me. I am not just copy and pasting other people&#39;s code, I could just give you a link if I was doing that, but I will not claim anything as to be straight from my own mind either.&lt;br /&gt;
****ENDNOTE****&lt;br /&gt;
&lt;br /&gt;
The following is a very basic Windows program using no DirectX to start with. This is the basis, the palette, upon which the rest of the DirectX will lay upon. So to start... Open up &lt;a href=&quot;http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-cpp-express&quot;&gt;Microsoft Visual C++ 2010 Express&lt;/a&gt; (click the link to download if you do not have it). When you first open up VC++ there is an option on the front screen to open a New Project, or you can click File-&amp;gt;New-&amp;gt;Project. You will see a screen like that below.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6pL5HacpUwULDD9-Jp9CO626qwTPuZ9Z4o6jvD592M58Hzr2MGNZ3H42wBOtAWYxorIkpulU6WK5NekcuL1ofR86KdkofK11pzQA5S-7Bl-fh6DaCu2QEGe7Mc0P7SAeUkaoQm-o0TeHA/s1600/New_Project_Window.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;245&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6pL5HacpUwULDD9-Jp9CO626qwTPuZ9Z4o6jvD592M58Hzr2MGNZ3H42wBOtAWYxorIkpulU6WK5NekcuL1ofR86KdkofK11pzQA5S-7Bl-fh6DaCu2QEGe7Mc0P7SAeUkaoQm-o0TeHA/s400/New_Project_Window.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;Click Browse to select the folder you want to put the project in, name your project, and select Empty Project, then OK to begin. You will then have an empty project in front of you that needs a file. Select File-&amp;gt;New-&amp;gt;File... or &amp;lt;CTRL&amp;gt;+&amp;lt;SHIFT&amp;gt;+&amp;lt;A&amp;gt; . Select &quot;.cpp&quot; as the type and name your .cpp file. I will use &quot;main.cpp&quot; to refer to this file from here on. Before we start coding let&#39;s go to Project-&amp;gt;Properties-&amp;gt;Configuration Properties-&amp;gt;General-&amp;gt;Character Set and change the character set from &quot;Use Unicode Character Set&quot; to &quot;Use Multi-Byte Character Set&quot;.&lt;br /&gt;
&lt;br /&gt;
Let&#39;s add some code:*/&lt;br /&gt;
&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;#include &amp;lt;Windows.h&amp;gt;&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;#define CLASS_NAME &amp;nbsp; &amp;nbsp; &quot;First Window&quot; &lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;#define WINDOW_NAME&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;First Window&quot;&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;#define WINDOW_WIDTH&amp;nbsp;&amp;nbsp;&amp;nbsp; 800&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;#define WINDOW_HEIGHT&amp;nbsp;&amp;nbsp; 600&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;HINSTANCE hInstance = NULL;&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;HWND hWnd = NULL;&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;bool InitWindow( HINSTANCE hInstance, int width, int height );&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;LRESULT CALLBACK WndProc( HWND, UINT, WPARAM, LPARAM );&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;/*This first part defines some global variables to create this first window. WINDOW_NAME, WINDOW_WIDTH, and WINDOW_HEIGHT are self explanatory. HINSTANCE is a windows type that holds the application instance(the executable module). HWND is a global variable that holds a Windows handle. I&#39;ll go more into what this is when we define it in InitWindow() but the handle holds the name, size, and style of the window we are creating.*/&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;{&amp;nbsp;&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Initialize the window&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if( !InitWindow( hInstance, WINDOW_WIDTH, WINDOW_HEIGHT))&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MessageBox(NULL, &quot;Initialization Failed!&quot;, &quot;Error!&quot;,&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MB_ICONEXCLAMATION | MB_OK);&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0;&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Main message loop&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MSG msg = {0};&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; while( msg.message != WM_QUIT)&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while(PeekMessage(&amp;amp;msg, NULL, 0, 0, PM_REMOVE) == TRUE)&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TranslateMessage(&amp;amp;msg);&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DispatchMessage(&amp;amp;msg);&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return (int)msg.wParam;&lt;br /&gt;
}&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: inherit;&quot;&gt;/*That code above is what takes the place of the typical C++ main() function.The first thing we do in our main function is initialize our window. We place the function &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;bool InitWindow() &lt;/span&gt;call in an if statement which will pop up a message box error and end our program if initialization fails. We then create a MSG handle which we will use to handle messages (mouse clicks, key strokes, etc.). &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;PeekMessage() &lt;/span&gt;can be replaced by &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;GetMessage()&lt;/span&gt; however &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;PeekMessage()&lt;/span&gt; is faster and is recommended in every game programming book I have read so far.&amp;nbsp; Now let&#39;s define our InitWindow() function there is a lot that goes into it but it&#39;s not as difficult as it looks at first:*/&lt;/div&gt;&lt;div style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;bool InitWindow( HINSTANCE hInstance, int width, int height )&lt;/span&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;{&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;  &amp;nbsp;WNDCLASSEX wncl;&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;memset(&amp;amp;wncl, 0,  sizeof(WNDCLASSEX));&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;wncl.cbSize = sizeof(WNDCLASSEX);&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;  &amp;nbsp;wncl.style = CS_HREDRAW | CS_VREDRAW;&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;wncl.lpfnWndProc =  WndProc;&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;wncl.hInstance = hInstance;&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;wncl.hIcon =  LoadIcon(NULL, IDI_APPLICATION);&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;wncl.hCursor =  LoadCursor(NULL, IDC_ARROW);&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;wncl.lpszClassName = CLASS_NAME;&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;  &amp;nbsp;wncl.hIconSm = LoadIcon(NULL, IDI_APPLICATION);&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;  &amp;nbsp;if(!RegisterClassEx(&amp;amp;wncl))&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;  &amp;nbsp;MessageBox(NULL, &quot;Window Class Registration Failed!&quot;, &quot;Error!&quot;,&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;MB_ICONEXCLAMATION | MB_OK);&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;return 0;&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;  &amp;nbsp;//Create the window from the class definition above&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;  &amp;nbsp;hWnd = CreateWindowEx(NULL,&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;CLASS_NAME,&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;WINDOW_NAME,&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;WS_OVERLAPPEDWINDOW,&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;CW_USEDEFAULT,&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;CW_USEDEFAULT,&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;width,&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;height,&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;  &amp;nbsp;NULL,&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;NULL,&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;  &amp;nbsp;hInstance,&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;NULL);&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;  &amp;nbsp;if(!hWnd)&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;return false;&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;  &amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;//Display the window&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;  &amp;nbsp;ShowWindow(hWnd, SW_SHOW);&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;UpdateWindow(hWnd);&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;  &amp;nbsp;return true;&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;}&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;/*A lot of new stuff there, all describing your window from the curs&lt;span style=&quot;font-family: Times,&amp;quot;Times New Roman&amp;quot;,serif;&quot;&gt;or type to Icons used and the background of your window. The explanation for this I think is better left to another post as this one is already getting lengthy. The process you see here you will begin to get used to using DirectX as you Create and Object-&amp;gt; Define the Object-&amp;gt;Register the Object.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Times,&amp;quot;Times New Roman&amp;quot;,serif;&quot;&gt; After defining and registering the window class, we then create a RECT object which is defined by the WINDOW_WIDTH and WINDOW_HEIGHT we input as variables to the InitWindow() function and sent to AdjustWindowRect() to resize the window. We then create the wind&lt;span style=&quot;font-family: Times,&amp;quot;Times New Roman&amp;quot;,serif;&quot;&gt;ow&lt;/span&gt; with the call to&lt;/span&gt; CreateWindow()*/&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;br style=&quot;font-family: Times,&amp;quot;Times New Roman&amp;quot;,serif;&quot; /&gt;&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;LRESULT CALLBACK WndProc( HWND hWnd, UINT message,&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WPARAM wParam, LPARAM lParam )&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;{&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Handle Messages&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; switch(message)&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; case WM_KEYDOWN:&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; switch(wParam)&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case VK_ESCAPE:&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PostQuitMessage(0);&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break; &lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; case WM_DESTROY:&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; PostQuitMessage(0);&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break;&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; return DefWindowProc(hWnd, message, wParam, lParam);&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;}&amp;nbsp; &lt;/div&gt;&lt;div style=&quot;font-family: Times,&amp;quot;Times New Roman&amp;quot;,serif;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: Times,&amp;quot;Times New Roman&amp;quot;,serif;&quot;&gt;&amp;nbsp;/*&lt;span style=&quot;font-family: inherit;&quot;&gt;You should be able to copy and paste this entry as a whole into your IDE and compile without any modifications. If you receive an error similar to&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt; &quot;Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast ... error C2440: &#39;=&#39; : cannot convert from &#39;const char [13]&#39; to &#39;LPCWSTR&#39;&quot; &lt;/span&gt;Then you have not set your character set to multi-byte. You can use the TEXT(&quot;Your text here&quot;) function instead but this is tiresome and unnecessary.&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font-family: Times,&amp;quot;Times New Roman&amp;quot;,serif;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: Times,&amp;quot;Times New Roman&amp;quot;,serif;&quot;&gt;I hope this has helped someone else in creating their first windows application. I recommend&lt;a href=&quot;http://www.winprog.org/tutorial/simple_window.html&quot;&gt; this site&lt;/a&gt; to get a more in depth understanding of the Win32 application we just created. */&lt;/div&gt;&lt;div style=&quot;font-family: Times,&amp;quot;Times New Roman&amp;quot;,serif;&quot;&gt;&amp;nbsp; &lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://geekspot-101.blogspot.com/feeds/4970156040380514998/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://geekspot-101.blogspot.com/2011/02/first-win32-application.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9066631589719297739/posts/default/4970156040380514998'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9066631589719297739/posts/default/4970156040380514998'/><link rel='alternate' type='text/html' href='http://geekspot-101.blogspot.com/2011/02/first-win32-application.html' title='First Win32 application'/><author><name>Geek Spot 101</name><uri>http://www.blogger.com/profile/09401800505792806961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6pL5HacpUwULDD9-Jp9CO626qwTPuZ9Z4o6jvD592M58Hzr2MGNZ3H42wBOtAWYxorIkpulU6WK5NekcuL1ofR86KdkofK11pzQA5S-7Bl-fh6DaCu2QEGe7Mc0P7SAeUkaoQm-o0TeHA/s72-c/New_Project_Window.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9066631589719297739.post-3120569855408871278</id><published>2011-02-05T12:17:00.000-08:00</published><updated>2011-02-05T19:20:50.954-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="DirectX"/><category scheme="http://www.blogger.com/atom/ns#" term="Game Programming"/><category scheme="http://www.blogger.com/atom/ns#" term="visual studio express"/><title type='text'>New Direction</title><content type='html'>Happy New Year Coders!&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; I have not posted in a while as school and life have been pretty busy but I&#39;m going to try starting this up again. I would like to change focus, however, to C++ and more specifically game programming and... hopefully... DirectX. I have heard a lot about how DirectX has a steep learning curve and I don&#39;t think it will be easy, but I think it is the direction I want to take for now. So, since my last posts I have completed Programming Logic and my first Computer Science class (C++). I will be starting on the second semester of C++ soon on my way to a Computer Science degree. I&#39;m also in Calculus 2 and from what I have seen of DirectX I will need a whole lot more math, so I can&#39;t wait to take Differential Equations and Linear Algebra in the coming semesters so I might understand the matrix translations I&#39;ll be dealing with in DirectX while programming my games. But that is getting ahead of myself.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; The main reason I wanted to start this up again is to help myself and give myself some practice as I am learning DirectX 10 on my own. I am going to try and start from the very beginning using the book Ultimate Game Programming with DirectX, Second Edition as my main guide using Microsoft Visual Studio 2010 .Net Express Edition as my IDE. When I get back I will post begin with getting started on the IDE and setting up a Win32 application.</content><link rel='replies' type='application/atom+xml' href='http://geekspot-101.blogspot.com/feeds/3120569855408871278/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://geekspot-101.blogspot.com/2011/02/new-direction.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9066631589719297739/posts/default/3120569855408871278'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9066631589719297739/posts/default/3120569855408871278'/><link rel='alternate' type='text/html' href='http://geekspot-101.blogspot.com/2011/02/new-direction.html' title='New Direction'/><author><name>Geek Spot 101</name><uri>http://www.blogger.com/profile/09401800505792806961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9066631589719297739.post-310261133392510851</id><published>2010-09-21T19:22:00.000-07:00</published><updated>2010-09-21T19:22:51.532-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="beginning programming"/><category scheme="http://www.blogger.com/atom/ns#" term="game"/><category scheme="http://www.blogger.com/atom/ns#" term="lists"/><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><title type='text'>Rock, Paper, Scissors, Pythons....?</title><content type='html'>Here&#39;s assignment for Logic turned Python. We were to describe the logic for an easy childhood game and I chose Rock, Paper, Scissors.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
import random&lt;br /&gt;
choices = [&#39;Rock&#39;,&#39;Paper&#39;,&#39;Scissors&#39;]&lt;br /&gt;
oppChoice=0&lt;br /&gt;
playerChoice=0&lt;br /&gt;
&lt;br /&gt;
def rock(oppChoice):&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if oppChoice == &#39;Rock&#39;:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print(&quot;It&#39;s a tie!&quot;)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if oppChoice == &#39;Paper&#39;:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print(&quot;You Lose! Paper covers Rock!&quot;)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if oppChoice == &#39;Scissors&#39;:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print(&quot;You Win! Rock smashes Scissors!&quot;)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
def paper(oppChoice):&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if oppChoice == &#39;Paper&#39;:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print(&quot;It&#39;s a tie!&quot;)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if oppChoice == &#39;Rock&#39;:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print(&quot;You Win! Paper covers Rock!&quot;)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if oppChoice == &#39;Scissors&#39;:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print(&quot;You Lose! Scissors cuts Paper!&quot;)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
def scissors(oppChoice):&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if oppChoice == &#39;Scissors&#39;:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print(&quot;It&#39;s a tie!&quot;)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if oppChoice == &#39;Paper&#39;:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print(&quot;You lose! Paper covers Rock!&quot;)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if oppChoice == &#39;Rock&#39;:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print(&quot;You Lose! Rock smashes Scissors!&quot;)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
def choice(playerChoice,oppChoice):&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if playerChoice==1:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rock(oppChoice)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if playerChoice==2:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; paper(oppChoice)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if playerChoice==3:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; scissors(oppChoice)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
def RPSgame():&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; oppChoice = random.choice(choices)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; playerChoice = input(&quot;Make your selection:\n[1] Rock\n[2] Paper\n[3] Scissors\n...&quot;)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; playerChoice=int(playerChoice)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if playerChoice not in(1,2,3):&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print(&quot;Please input 1, 2, or 3 only!&quot;)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RPSgame()&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; print(&#39;You Chose&#39;, choices[playerChoice-1])&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; print(&#39;Your Opponent Chose...&#39;,oppChoice)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; choice(playerChoice,oppChoice)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; playAgain = input(&quot;Try again? (Y,N)&quot;)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if playAgain== &#39;Y&#39; or &#39;y&#39;:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RPSgame()&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; else: return&lt;br /&gt;
&lt;br /&gt;
The first 44 lines are the game&#39;s logic, just telling you if you won or lost based on your choice vs. opponent&#39;s choice. The &quot;main&quot; code is RPSgame() which, if you ran this code, is all you would have to type to start the game. I tried to account for incorrect input (not using 1,2, or 3 for initial input and disregard for capitalization for &quot;y&quot; to continue playing). The only thing in here we haven&#39;t covered thus far on the GeekSpot Blog is the use of lists. I will go into that more in depth later this week when I have more time. In the mean time, I&#39;ll leave it at:&lt;br /&gt;
&lt;br /&gt;
Lists are built in brackets: []&lt;br /&gt;
Lists are mutable: They can be changed... added to, taken away from...&lt;br /&gt;
List elements are numbered starting from 0: choice[0] thus equals Rock.&lt;br /&gt;
&lt;br /&gt;
There is much more to lists, lists can be used for many things and have much potential in your programming. Thanks for stopping by! If anyone has suggestions, comments or concerns about the above code, please feel free to leave a post or shoot me an email.</content><link rel='replies' type='application/atom+xml' href='http://geekspot-101.blogspot.com/feeds/310261133392510851/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://geekspot-101.blogspot.com/2010/09/rock-paper-scissors-pythons.html#comment-form' title='8 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9066631589719297739/posts/default/310261133392510851'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9066631589719297739/posts/default/310261133392510851'/><link rel='alternate' type='text/html' href='http://geekspot-101.blogspot.com/2010/09/rock-paper-scissors-pythons.html' title='Rock, Paper, Scissors, Pythons....?'/><author><name>Geek Spot 101</name><uri>http://www.blogger.com/profile/09401800505792806961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9066631589719297739.post-926639358646013477</id><published>2010-09-18T21:07:00.000-07:00</published><updated>2010-09-18T21:07:39.621-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="beginning programming"/><category scheme="http://www.blogger.com/atom/ns#" term="define"/><category scheme="http://www.blogger.com/atom/ns#" term="docstring"/><category scheme="http://www.blogger.com/atom/ns#" term="functions"/><category scheme="http://www.blogger.com/atom/ns#" term="programming"/><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><title type='text'>Defining Functions</title><content type='html'>Functions. What are they?&lt;br /&gt;
&lt;br /&gt;
In math you know a function as f(x)=3x+3. substitute any number for x and you get a value. Typically a function is used to define something, such as the rate of change in speed of a car, or a runner. One variable is time, the other is speed. If you plug the value in for one your can get the other, as long as they follow the rules of the function created to define their motion (which for now we are assuming they do). If you wanted to write that same function in Python, and all you wanted it to do is print out the value, you could write:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;def function(x):&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; print(4*x+2)&lt;br /&gt;
&lt;br /&gt;
Now every time you want to call the function, you only have to type, say...&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;function(3)&lt;br /&gt;
14&lt;br /&gt;
&lt;br /&gt;
The value x in &quot;def function(x)&quot; replaces the x in the indented lines following the defining statement and your function runs, printing 4 * &lt;b&gt;3&lt;/b&gt; + 2. But the function doesn&#39;t have to take a value.&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt;def declaration():&lt;br /&gt;
&amp;nbsp; &amp;nbsp; print(&quot;When in the Course of human events.&quot;)&lt;br /&gt;
&lt;br /&gt;
Here the function just prints out what the function is. A benefit to functions is that you can &lt;b&gt;modularize&lt;/b&gt; your program. You can break it up into it&#39;s basic functions which can then be used over and over again, not only in that program but in others as well. If you create a function that asks for a user name, you can use that in any program that requires the user to input their name.&lt;br /&gt;
&lt;br /&gt;
You can also nest functions. Such as...&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;def repeat(f):&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; f()&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; f()&lt;br /&gt;
&lt;br /&gt;
This function takes a function name as it&#39;s input and outputs that function twice.&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt;repeat(declaration)&lt;br /&gt;
When in the Course of human events.&lt;br /&gt;
When in the Course of human events.&lt;br /&gt;
&lt;br /&gt;
You may have noticed when you typed repeat( ... a helpful box comes up with (f), reminding you that the function takes f as it&#39;s value. But this isn&#39;t always helpful. You could instead write a &lt;b&gt;docstring&lt;/b&gt;, or documentation string, giving more helpful information to remind you and others what to input here. You do this by placing three double quotes before and after as shown.&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;def repeat(f):&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;&quot;&quot;Input a function name here&quot;&quot;&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; f()&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; f()&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjj6C-ttFBYy9Gd3_KaKtRAnFzftWgL2urG-Hp2Kmg9HzRdwJivKvmmgxQQ2s-LpmZbONNyRslMJ_RjgjY3HvnKVhPoTsNssqHpgty56u_pOlQySvqf1mrLu5HAy55RF41bfB8-I5cFJhtW/s1600/repeat.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;157&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjj6C-ttFBYy9Gd3_KaKtRAnFzftWgL2urG-Hp2Kmg9HzRdwJivKvmmgxQQ2s-LpmZbONNyRslMJ_RjgjY3HvnKVhPoTsNssqHpgty56u_pOlQySvqf1mrLu5HAy55RF41bfB8-I5cFJhtW/s400/repeat.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;This is what it should look like. There are many, many uses for functions in programming. We&#39;ll be using functions in most, if not all, of the posts from here on out.</content><link rel='replies' type='application/atom+xml' href='http://geekspot-101.blogspot.com/feeds/926639358646013477/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://geekspot-101.blogspot.com/2010/09/defining-functions.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9066631589719297739/posts/default/926639358646013477'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9066631589719297739/posts/default/926639358646013477'/><link rel='alternate' type='text/html' href='http://geekspot-101.blogspot.com/2010/09/defining-functions.html' title='Defining Functions'/><author><name>Geek Spot 101</name><uri>http://www.blogger.com/profile/09401800505792806961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjj6C-ttFBYy9Gd3_KaKtRAnFzftWgL2urG-Hp2Kmg9HzRdwJivKvmmgxQQ2s-LpmZbONNyRslMJ_RjgjY3HvnKVhPoTsNssqHpgty56u_pOlQySvqf1mrLu5HAy55RF41bfB8-I5cFJhtW/s72-c/repeat.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9066631589719297739.post-7498384411849088491</id><published>2010-09-15T20:11:00.000-07:00</published><updated>2010-09-15T20:11:28.629-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="game"/><category scheme="http://www.blogger.com/atom/ns#" term="number"/><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><category scheme="http://www.blogger.com/atom/ns#" term="random"/><title type='text'>Random Number Game - Python</title><content type='html'>In my logic class we were instructed to produce &lt;b&gt;psuedocode&lt;/b&gt; for a program that produces a random number 1-10, asks the user to input a number, and outputs both numbers. Here is my version and the python code for it:&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Start&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;Declarations&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp; int randomNumber = random(10)&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp; int guess = 0&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;output &quot;Guess my number! (1-10)&quot;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;input guess&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;while guess != randomNumber &lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp; if guess == randomNumber&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp; &amp;nbsp; output &quot;Good Job!&quot;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp; else&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output &quot;Sorry you&#39;re wrong&quot;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if guess &amp;lt; randomNumber&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output &quot;Guess too Low. Try again.&quot;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output &quot;Guess too High. Try again.&quot;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;Stop&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
The nice thing about &lt;b&gt;Python&lt;/b&gt; is that it is not much different than psuedocode, we just have to pay attention to the syntax. The only thing new here from previous posts is the random number generator which you will see below.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;#Start&lt;br /&gt;
import random&amp;nbsp;&amp;nbsp;&amp;nbsp; # Necessary to call random later&lt;br /&gt;
randomNumber=random.randint(1,10)&lt;br /&gt;
guess=0&lt;br /&gt;
while guess != randomNumber:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; guess=int(input(&quot;Pick a number 1-10: &quot;))&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if guess == randomNumber:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print(&quot;Good Job!&quot;)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print(&quot;Sorry you&#39;re wrong.&quot;)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if guess &amp;lt; randomNumber:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print(&quot;Guess too low. Try again.&quot;)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:print(&quot;Guess too high. Try again.&quot;)&lt;br /&gt;
#Stop&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
I used random.randint(x,y), x and y being low and high values respectively, to generate my number. You could also have used random.randrange(x,y,z) with x as low value, y as high value, and z being step. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt;random.randrange(0,100,10)&lt;br /&gt;
80&lt;br /&gt;
&lt;br /&gt;
The above code generates a random number 0 through 100 at steps of 10 (i.e. 10, 20, 30,...). How would you produce the above &quot;game&quot;?</content><link rel='replies' type='application/atom+xml' href='http://geekspot-101.blogspot.com/feeds/7498384411849088491/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://geekspot-101.blogspot.com/2010/09/random-number-game-python.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9066631589719297739/posts/default/7498384411849088491'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9066631589719297739/posts/default/7498384411849088491'/><link rel='alternate' type='text/html' href='http://geekspot-101.blogspot.com/2010/09/random-number-game-python.html' title='Random Number Game - Python'/><author><name>Geek Spot 101</name><uri>http://www.blogger.com/profile/09401800505792806961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9066631589719297739.post-4219224898748087094</id><published>2010-09-14T15:53:00.000-07:00</published><updated>2010-09-14T15:53:07.753-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="beginning programming"/><category scheme="http://www.blogger.com/atom/ns#" term="break"/><category scheme="http://www.blogger.com/atom/ns#" term="for"/><category scheme="http://www.blogger.com/atom/ns#" term="loops"/><category scheme="http://www.blogger.com/atom/ns#" term="modulo"/><category scheme="http://www.blogger.com/atom/ns#" term="prime"/><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><category scheme="http://www.blogger.com/atom/ns#" term="while"/><title type='text'>Finding the 1000th Prime</title><content type='html'>I mentioned the other day the homework assignment for MIT OCW Intro to CS course was to find the 1000th square root. Here is a possible solution to the problem:&lt;br /&gt;
&lt;br /&gt;
primeCheck = 5&lt;br /&gt;
primeCount = 3&lt;br /&gt;
while primeCount &amp;lt;= 1000:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; for divisor in range(2, primeCheck//2+1):&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; remainder = primeCheck % divisor&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if remainder == 0:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; primeCount += 1&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; primeCheck += 1&lt;br /&gt;
print(primeCheck - 1)&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;i&gt;&lt;b&gt;*Note - Thanks go out to &lt;a href=&quot;http://www.dreamincode.net/forums/topic/189885-1000th-prime/&quot;&gt;Nallo&lt;/a&gt; who helped make my original code with clarity. &lt;/b&gt;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
You can see we&#39;ve got a few new things here. The while loop on line 3, the for loop in line 4, and a few new uses for our operators. I started explaining everything new here and it became a fairly long explanation I split into two other posts so if you want the explanation you can go there and if you just wanted to see the code you can stop here. We could also have changed 1000 to &lt;i&gt;variable&lt;/i&gt; and inserted &amp;gt;&amp;gt;&amp;gt;variable = input(&quot;What prime number do you want&quot;) in the front to make this code find &lt;b&gt;just about&lt;/b&gt; any prime.&lt;br /&gt;
The result is 7919 which you can also see here: &lt;a href=&quot;http://primes.utm.edu/lists/small/1000.txt&quot;&gt;List of 1000 Primes&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Related posts:&lt;/b&gt;&lt;br /&gt;
&lt;a href=&quot;http://geekspot-101.blogspot.com/2010/09/finding-1000th-prime-explanation.html&quot;&gt;Finding the 1000th Prime: Explanation&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://geekspot-101.blogspot.com/2010/09/while-loop-in-python.html&quot;&gt;While Loops&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://geekspot-101.blogspot.com/2010/09/declaring-variables-w-python.html&quot;&gt;Declaring Variables with Python&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://geekspot-101.blogspot.com/2010/09/order-of-operations-and-naming.html&quot;&gt;Order of Operations&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://geekspot-101.blogspot.com/feeds/4219224898748087094/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://geekspot-101.blogspot.com/2010/09/finding-1000th-prime.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9066631589719297739/posts/default/4219224898748087094'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9066631589719297739/posts/default/4219224898748087094'/><link rel='alternate' type='text/html' href='http://geekspot-101.blogspot.com/2010/09/finding-1000th-prime.html' title='Finding the 1000th Prime'/><author><name>Geek Spot 101</name><uri>http://www.blogger.com/profile/09401800505792806961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9066631589719297739.post-8661060460263462553</id><published>2010-09-14T15:52:00.000-07:00</published><updated>2010-09-14T15:52:46.738-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="beginning programming"/><category scheme="http://www.blogger.com/atom/ns#" term="break"/><category scheme="http://www.blogger.com/atom/ns#" term="counter"/><category scheme="http://www.blogger.com/atom/ns#" term="for"/><category scheme="http://www.blogger.com/atom/ns#" term="prime"/><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><category scheme="http://www.blogger.com/atom/ns#" term="while"/><title type='text'>Finding the 1000th Prime: Explanation</title><content type='html'>This is the explanation for the code for 1000th prime.&lt;br /&gt;
Here&#39;s the code again:&lt;br /&gt;
&lt;br /&gt;
primeCheck = 5&lt;br /&gt;
primeCount = 3&lt;br /&gt;
while primeCount &amp;lt;= 1000:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; for divisor in range(2, primeCheck//2+1):&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; remainder = primeCheck % divisor&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if remainder == 0:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; primeCount += 1&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; primeCheck += 1&lt;br /&gt;
print(primeCheck - 1)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I started our prime checker with 5 which is the 3rd prime. This is  why the variable primeCount is 3, as it is checking for the 3rd prime.  If 5 passes the test (which it does) the count will go to 4 and it will  search for the fourth one. I&#39;m using the while loop to continually  repeat everything below and indented right of the while. The test for  primality I have used is checking to see what the remainder is when  applying the modulo operator to the possible prime and numbers 2 through  half of the possible prime. It is not necessary to go further than this  since all numbers above are inherently tested by testing the numbers  below half.&lt;br /&gt;
&lt;br /&gt;
The while loop was explained &lt;a href=&quot;http://geekspot-101.blogspot.com/2010/09/while-loop-in-python.html&quot;&gt;here,&lt;/a&gt; so I will move on to the for loop. &lt;b&gt;The for loop &lt;/b&gt;is used when you know when you want your loop to end. We have a starting point (here it is 2) and an end (primeCheck//2+1).  There are many ways to use a for loop, and the nice thing about it is  you do not have to specify a counter (a variable that continually  increases with each repetition of the loop, our while loop uses  primeCount as the counter), it goes to the end and repeats until the end  value is met.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Our end value to our for loop is primeCheck//2+1, which takes the  number we are checking, 5 for instance, and does integer division on it  ( // ), which gives us 2 rather than 2.5 if we used /. (Unless you are  using pre-Python3 which divides based on your type and would also give  two unless we changed a value to float).&lt;br /&gt;
&lt;br /&gt;
Our next line is &lt;b&gt;remainder = primeCheck % divisor, &lt;/b&gt;which  performs modulo division on primeCheck by divisor. What is the modulo  operator? The modulo operator is the % sign and it gives you the  remainder after division of any two numbers. Here&#39;s a few examples to  help you understand:&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;4%2&lt;br /&gt;
0&lt;br /&gt;
&lt;br /&gt;
This is because 4/2=2 with no remainder.&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;5%2&lt;br /&gt;
1&lt;br /&gt;
&lt;br /&gt;
Because 5/2=2 with a remainder of 1.&lt;br /&gt;
This  is why it makes sense to use it in our test, because a prime should not  be divisible by a whole number integer evenly. If it does (if x==0)  then the number is not prime and &lt;b&gt;break&lt;/b&gt; is called which stops the  loop there and starts again at the next value. The first 0 remainder we  find is proof enough that that number is not a prime.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
And that&#39;s as simple as it is, our for loop is nested within our  while loop, every time the for loop finds another prime the counter for  primes goes up and when it meets our requirement of 1000 it stops and  prints the value. The reason for the &lt;b&gt;-1 &lt;/b&gt;at the end would be  because even after if finds the 1000th prime it finishes with the  primeCheck+=1 which we have to negate at the end.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1000th Prime = 7919&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here is a &lt;a href=&quot;http://primes.utm.edu/lists/small/1000.txt&quot;&gt;list of the first 1000 primes&lt;/a&gt; if you want extra validation. &lt;br /&gt;
See more interesting Python below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;object height=&quot;385&quot; width=&quot;480&quot;&gt;&lt;param name=&quot;movie&quot; value=&quot;http://www.youtube.com/v/teMlv3ripSM?fs=1&amp;amp;hl=en_US&quot;&gt;&lt;/param&gt;&lt;param name=&quot;allowFullScreen&quot; value=&quot;true&quot;&gt;&lt;/param&gt;&lt;param name=&quot;allowscriptaccess&quot; value=&quot;always&quot;&gt;&lt;/param&gt;&lt;embed src=&quot;http://www.youtube.com/v/teMlv3ripSM?fs=1&amp;amp;hl=en_US&quot; type=&quot;application/x-shockwave-flash&quot; allowscriptaccess=&quot;always&quot; allowfullscreen=&quot;true&quot; width=&quot;480&quot; height=&quot;385&quot;&gt;&lt;/embed&gt;&lt;/object&gt;</content><link rel='replies' type='application/atom+xml' href='http://geekspot-101.blogspot.com/feeds/8661060460263462553/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://geekspot-101.blogspot.com/2010/09/finding-1000th-prime-explanation.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9066631589719297739/posts/default/8661060460263462553'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9066631589719297739/posts/default/8661060460263462553'/><link rel='alternate' type='text/html' href='http://geekspot-101.blogspot.com/2010/09/finding-1000th-prime-explanation.html' title='Finding the 1000th Prime: Explanation'/><author><name>Geek Spot 101</name><uri>http://www.blogger.com/profile/09401800505792806961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9066631589719297739.post-8267640415984107723</id><published>2010-09-12T08:42:00.000-07:00</published><updated>2010-09-12T08:44:10.460-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="assignment operator"/><category scheme="http://www.blogger.com/atom/ns#" term="comparison operator"/><category scheme="http://www.blogger.com/atom/ns#" term="counter"/><category scheme="http://www.blogger.com/atom/ns#" term="loop"/><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><category scheme="http://www.blogger.com/atom/ns#" term="while"/><title type='text'>The While Loop in Python</title><content type='html'>The while loop says that while one thing is true, do something. Here we can count to ten:&lt;br /&gt;
&lt;br /&gt;
counter=0&lt;br /&gt;
while counter &amp;lt; 11:&lt;br /&gt;
&amp;nbsp;print(counter)&lt;br /&gt;
&amp;nbsp;counter=counter+1&lt;br /&gt;
&lt;br /&gt;
What did we do here? First we &lt;b&gt;initilized&lt;/b&gt; counter as 0, this is where our counter is starting. It is important to initialize the variable you are using in your while loop &lt;b&gt;outside &lt;/b&gt;of the loop. After we have initialized counter to 0 we say: While the value of counter is less than 11, do something. In our case, do something is print(counter), which the first time through would be 0, and then we set counter equal to itself plus one.&lt;br /&gt;
&lt;br /&gt;
Our loop will now continue with counter as 1 print one and add 1 to itself. When counter is equal to 10, it goes through one last time, prints 10 adds one to 11 and then passes through the while test again. This time it is not less than 11, because it equals 11 and so it stops. Your output should be:&lt;br /&gt;
&lt;br /&gt;
0&lt;br /&gt;
1&lt;br /&gt;
2&lt;br /&gt;
3&lt;br /&gt;
4&lt;br /&gt;
5&lt;br /&gt;
6&lt;br /&gt;
7&lt;br /&gt;
8&lt;br /&gt;
9&lt;br /&gt;
10&lt;br /&gt;
&lt;br /&gt;
We can say this same thing but, in my opinion, make it look nicer. We can do this by making use of multiple operators. The first example will be in line 2, instead of &amp;lt; 11, we can use &amp;lt;=10, which is less than or equal to. A list of such comparison operators is:&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;&amp;lt;= &amp;nbsp; &amp;nbsp; If left operand is less than or equal to right operand, condition is true.&lt;/div&gt;&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;&amp;gt;=&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If left operand is greater than or equal to right operand, condition is true&lt;/div&gt;&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;== &amp;nbsp; &amp;nbsp; If left operand is equal to right operand, condition is true.&lt;/div&gt;&lt;span style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;!= &amp;nbsp; &amp;nbsp;&amp;nbsp; If left operand is not equal to right operand, condition is true.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;Notice the difference between the assignment operator = and the conditional operator ==. The first makes one operand equal another, the other tests the equality of the two operands.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;The second way we can simplify the program is by using the compound assignment operator +=. In line 4, where we say counter=counter+1, the same thing could be said with the expression, counter+=1. This takes the value of counter, adds one and assigns that value to counter. You can see how this be of use. Here are some more compound assignment operators:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;+=&amp;nbsp; Adds left and right operand and assigns total to left operand&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;-=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt; Subracts right from left operand and assigns total to left operand&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;*=Multiplies&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt; left and right operand and assigns total to left operand&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;/=&lt;/span&gt;&lt;span style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt; Divides right from left operand and assigns total to left operand&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;**=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt; Takes left operand to the power of the right operand and assigns total to left operand&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;%=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt; Finds remainder of division between left operand and right operand, and assigns total to left operand.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;//= &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;Performs integer division between left and right operand and assigns total to left operand&lt;/span&gt;&lt;span style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;Our &quot;improved&quot; code would now be:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
counter=0&lt;br /&gt;
while counter &amp;lt;= 10:&lt;br /&gt;
&amp;nbsp;print(counter)&lt;br /&gt;
&amp;nbsp;counter+=1</content><link rel='replies' type='application/atom+xml' href='http://geekspot-101.blogspot.com/feeds/8267640415984107723/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://geekspot-101.blogspot.com/2010/09/while-loop-in-python.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9066631589719297739/posts/default/8267640415984107723'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9066631589719297739/posts/default/8267640415984107723'/><link rel='alternate' type='text/html' href='http://geekspot-101.blogspot.com/2010/09/while-loop-in-python.html' title='The While Loop in Python'/><author><name>Geek Spot 101</name><uri>http://www.blogger.com/profile/09401800505792806961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9066631589719297739.post-2964016060844080352</id><published>2010-09-11T14:08:00.000-07:00</published><updated>2010-09-11T14:08:34.012-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="beginning programming"/><category scheme="http://www.blogger.com/atom/ns#" term="camel case"/><category scheme="http://www.blogger.com/atom/ns#" term="legal variable names"/><category scheme="http://www.blogger.com/atom/ns#" term="naming"/><category scheme="http://www.blogger.com/atom/ns#" term="operand"/><category scheme="http://www.blogger.com/atom/ns#" term="operator"/><category scheme="http://www.blogger.com/atom/ns#" term="order of operations"/><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><category scheme="http://www.blogger.com/atom/ns#" term="variables"/><title type='text'>Order of Operations and Naming Conventions</title><content type='html'>&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjD_yoDs5ZWWgjazq4DzlcbH_TV5oAmNdCEZ2_hYW9GPo8vzrzHwkho1aEI6ozqsqfqXfzf8qvQSIyptf49bblrr6JEk7l5jss8PXq9FVGPRqMWkT94FJkslQx9jslCUAJGvHm9gXk30yKr/s1600/orderofoperations.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjD_yoDs5ZWWgjazq4DzlcbH_TV5oAmNdCEZ2_hYW9GPo8vzrzHwkho1aEI6ozqsqfqXfzf8qvQSIyptf49bblrr6JEk7l5jss8PXq9FVGPRqMWkT94FJkslQx9jslCUAJGvHm9gXk30yKr/s320/orderofoperations.jpg&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Order of Operations&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;Yesterday we went over operators and operands. Today I&#39;d like to go over Order of Operations. When you were going through elementary or middle school math you may have learned a similar way to remember it and mathematical order of operations is the same here. I learned it as, &lt;b&gt;P&lt;/b&gt;lease &lt;b&gt;E&lt;/b&gt;xcuse &lt;b&gt;M&lt;/b&gt;y &lt;b&gt;D&lt;/b&gt;ear &lt;b&gt;A&lt;/b&gt;unt &lt;b&gt;S&lt;/b&gt;ally, or &lt;b&gt;P&lt;/b&gt;arenthesis, &lt;b&gt;E&lt;/b&gt;xponents, &lt;b&gt;M&lt;/b&gt;ultiplication/&lt;b&gt;D&lt;/b&gt;ivision (both have the same precedence), &lt;b&gt;A&lt;/b&gt;ddition/&lt;b&gt;S&lt;/b&gt;ubtraction (so do they). You can also remember, as offered by &lt;a href=&quot;http://www.greenteapress.com/thinkpython/thinkCSpy/&quot;&gt;Thinking Like a Computer Scientist&lt;/a&gt;, the acronym &lt;b&gt;PEMDAS&lt;/b&gt;. I like mnemonics so the former works better for me. I made it a point to list them in order in the last post.&lt;br /&gt;
&lt;br /&gt;
Here are a few examples. Try to figure out what the results should be. You can also test it (and me) by putting the operation into the Python Shell to see for yourself what it comes out to.&lt;br /&gt;
&lt;br /&gt;
8*1**4 = ?&lt;br /&gt;
3-6/3 = ?&lt;br /&gt;
(8*2)**4 = ?&lt;br /&gt;
12*2/4+4-2 = ? &lt;br /&gt;
&lt;br /&gt;
The first example comes out to... &lt;b&gt;8&lt;/b&gt;! Because 1 exponent 4 is still one, times 8 is still 8. The second example is &lt;b&gt;1&lt;/b&gt;, because we first divide 6 by 3 then subtract the result from 3. Making sense? This next one is the same as the first one but notice the parenthesis. This will now do the parenthesis first, giving us 16 and taking 16 to the exponent 4 which gives us &lt;b&gt;65536&lt;/b&gt;. For the last one we have multiple operations with the same precedence. How will Python evaluate it? The same as you would read it, left to right. It would take 12*2 to get 24, 24/4 to get 6, 6+4 to get 10, and 10-2 to get &lt;b&gt;8&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
We&#39;ve also gone over variables, but not the naming conventions of them. There are some rules, and there are some style suggestions. Some rules are:&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Variable names cannot begin with a number.&lt;/li&gt;
&lt;li&gt;All numbers are legal (Just not to begin the variable name)&lt;/li&gt;
&lt;li&gt;Variable names cannot contain the character $. &lt;/li&gt;
&lt;li&gt;Variable names cannot be a keyword &lt;i&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;(see list below)&lt;/span&gt;&lt;/i&gt;&lt;/li&gt;
&lt;li&gt;Multiple variabls cannot share the same name.&lt;/li&gt;
&lt;li&gt;Variable names are case sensitive. (i.e. name is separate from Name)&lt;/li&gt;
&lt;li&gt;Variable names cannot include a space.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Variable name must be on the left side of the assignment operator. &lt;/li&gt;
&lt;/ol&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;False&lt;/span&gt;      &lt;span class=&quot;k&quot;&gt;class&lt;/span&gt;      &lt;span class=&quot;nc&quot;&gt;finally&lt;/span&gt;    &lt;span class=&quot;ow&quot;&gt;is&lt;/span&gt;         &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;None&lt;/span&gt;       &lt;span class=&quot;k&quot;&gt;continue&lt;/span&gt;   &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt;        &lt;span class=&quot;k&quot;&gt;lambda&lt;/span&gt;     &lt;span class=&quot;k&quot;&gt;try&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;True&lt;/span&gt;       &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt;        &lt;span class=&quot;nf&quot;&gt;from&lt;/span&gt;       &lt;span class=&quot;n&quot;&gt;nonlocal&lt;/span&gt;   &lt;span class=&quot;k&quot;&gt;while&lt;/span&gt;
&lt;span class=&quot;ow&quot;&gt;and&lt;/span&gt;        &lt;span class=&quot;k&quot;&gt;del&lt;/span&gt;        &lt;span class=&quot;k&quot;&gt;global&lt;/span&gt;     &lt;span class=&quot;ow&quot;&gt;not&lt;/span&gt;        &lt;span class=&quot;k&quot;&gt;with&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;as&lt;/span&gt;         &lt;span class=&quot;k&quot;&gt;elif&lt;/span&gt;       &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;         &lt;span class=&quot;ow&quot;&gt;or&lt;/span&gt;         &lt;span class=&quot;k&quot;&gt;yield&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;assert&lt;/span&gt;     &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;       &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt;     &lt;span class=&quot;nn&quot;&gt;pass&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;break&lt;/span&gt;      &lt;span class=&quot;k&quot;&gt;except&lt;/span&gt;     &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt;         &lt;span class=&quot;k&quot;&gt;raise&lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;br /&gt;
As for style, there are a few general suggestions. One is to use meaningful names. This helps you when you have to go back to your code later on and interpret it, and it helps others know what is going on. This goes along with leaving comments in your code. Another suggestion is to use _ to break up words in a variable name, such as coffee_made = no. You can also use what is called camel case. Camel case is what I prefer and is when you capitalize the first letter in each word excluding the first and include no spaces, such as coffeeMade = no. According to &lt;a href=&quot;http://en.wikipedia.org/wiki/CamelCase&quot;&gt;Wiki&lt;/a&gt;, if you capitalize the beginning as well it is known as Pascal case.&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqkA2icwfQ-GEDsVQfGyKKvSBpngKk1tsJhxbcI36hprCpI7UpRCj9_4bt2aCo_fhgEtde8dUcHgaOYj8j7YybTR8K7dfoJmU-dDuLuu1INJltJoeE0auy-pbJBp4o59gkVege_KTrWuw7/s1600/368px-CamelCase.svg.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqkA2icwfQ-GEDsVQfGyKKvSBpngKk1tsJhxbcI36hprCpI7UpRCj9_4bt2aCo_fhgEtde8dUcHgaOYj8j7YybTR8K7dfoJmU-dDuLuu1INJltJoeE0auy-pbJBp4o59gkVege_KTrWuw7/s320/368px-CamelCase.svg.png&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Sorry, I like the camel.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;</content><link rel='replies' type='application/atom+xml' href='http://geekspot-101.blogspot.com/feeds/2964016060844080352/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://geekspot-101.blogspot.com/2010/09/order-of-operations-and-naming.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9066631589719297739/posts/default/2964016060844080352'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9066631589719297739/posts/default/2964016060844080352'/><link rel='alternate' type='text/html' href='http://geekspot-101.blogspot.com/2010/09/order-of-operations-and-naming.html' title='Order of Operations and Naming Conventions'/><author><name>Geek Spot 101</name><uri>http://www.blogger.com/profile/09401800505792806961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjD_yoDs5ZWWgjazq4DzlcbH_TV5oAmNdCEZ2_hYW9GPo8vzrzHwkho1aEI6ozqsqfqXfzf8qvQSIyptf49bblrr6JEk7l5jss8PXq9FVGPRqMWkT94FJkslQx9jslCUAJGvHm9gXk30yKr/s72-c/orderofoperations.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9066631589719297739.post-258456445115300147</id><published>2010-09-10T21:02:00.000-07:00</published><updated>2010-09-10T21:02:46.048-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="beginning programming"/><category scheme="http://www.blogger.com/atom/ns#" term="convert"/><category scheme="http://www.blogger.com/atom/ns#" term="float"/><category scheme="http://www.blogger.com/atom/ns#" term="integer"/><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><category scheme="http://www.blogger.com/atom/ns#" term="string"/><category scheme="http://www.blogger.com/atom/ns#" term="types"/><title type='text'>Converting Data Types in Python</title><content type='html'>If you remember so far we have mentioned three types, int, float, and str. For those who don&#39;t remember int is integer and is a whole number integer (3 and 91 for example). Float is floating point and has a decimal value (7.2 or even 9.0) and str is string or a string of characters (&quot;Hello, World&quot; is a string). To convert between types Python allows the following:&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Convert to integer:&lt;/b&gt;&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;int(&quot;29&quot;)&lt;br /&gt;
29&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;x=5&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;int(x)&lt;br /&gt;
5&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;int(3.14159)&lt;br /&gt;
3&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Convert to float:&lt;/b&gt;&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;float(&quot;3.14159&quot;)&lt;br /&gt;
3.14159&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;float 5&lt;br /&gt;
5.0&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Convert to string:&lt;/b&gt;&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;str(3.14159)&lt;br /&gt;
&#39;3.14159&#39;&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;str(42)&lt;br /&gt;
&#39;42&#39;&lt;br /&gt;
&lt;br /&gt;
You can also test to see what type you have. You do this by using the type() function call. Here are some examples.&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;type(&#39;42&#39;)&lt;br /&gt;
&amp;lt;class &#39;str&#39;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;type(4.2)&lt;br /&gt;
&amp;lt;class &#39;float&#39;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;As the class I am following online is using an older version of Python I&#39;m trying to keep up with the new rules but I may (will) miss some. I started running them on the new one so I can learn it better and hopefully this will fix the discrepancies I&#39;ve been having. &lt;a href=&quot;http://diveintopython3.org/porting-code-to-python-3-with-2to3.html&quot;&gt;Here is a site &lt;/a&gt;that has a lot of the new changes. &lt;/span&gt;&lt;/b&gt;&lt;/i&gt;</content><link rel='replies' type='application/atom+xml' href='http://geekspot-101.blogspot.com/feeds/258456445115300147/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://geekspot-101.blogspot.com/2010/09/converting-data-types-in-python.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9066631589719297739/posts/default/258456445115300147'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9066631589719297739/posts/default/258456445115300147'/><link rel='alternate' type='text/html' href='http://geekspot-101.blogspot.com/2010/09/converting-data-types-in-python.html' title='Converting Data Types in Python'/><author><name>Geek Spot 101</name><uri>http://www.blogger.com/profile/09401800505792806961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9066631589719297739.post-7402123211655626478</id><published>2010-09-10T16:15:00.000-07:00</published><updated>2010-09-10T21:42:19.276-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="beginning programming"/><category scheme="http://www.blogger.com/atom/ns#" term="input"/><category scheme="http://www.blogger.com/atom/ns#" term="output"/><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><title type='text'>Input and Output in Python</title><content type='html'>Computers have three major operations, the sole reason they exist. These are input, processing, and output. If they computer couldn&#39;t do one of these it would become practically useless. You input data with every movement of the mouse and every button pressed on the keyboard. The computer processes that data into something, a movement of the cursor, a character typed, and outputs that data to the screen so you can see where the computer thinks the cursor is and what character you typed on the monitor. So far we have placed our variables and their values within the program itself so the user has no interaction with it. They click, it runs. Now let&#39;s try building an interactive program.&lt;br /&gt;
&lt;br /&gt;
If you checked out the MIT OCW Introduction to Computer Science and Programming course you may have seen the first homework assignment was to create a program with the following requirements:&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Problem 1.&lt;/b&gt;&lt;br /&gt;
Write a program that does the following in order:&lt;br /&gt;
1. Asks the user to enter his/her last name.&lt;br /&gt;
2. Asks the user to enter his/her first name.&lt;br /&gt;
3. Prints out the user’s first and last names in that order.&lt;br /&gt;
&lt;br /&gt;
Before we start writing code, we can create pseudocode.&lt;br /&gt;
&lt;br /&gt;
Start&lt;br /&gt;
input lastName&lt;br /&gt;
input firstName&lt;br /&gt;
output firstName lastName.&lt;br /&gt;
Stop&lt;br /&gt;
&lt;br /&gt;
This would do the job, but how does the user know which name to put first or that you want them to enter a name at all? You can ask them, with:&lt;br /&gt;
&lt;br /&gt;
Start&lt;br /&gt;
output &quot;What is your Last Name? &quot;&lt;br /&gt;
input lastName&lt;br /&gt;
output &quot;What is your First Name? &quot;&lt;br /&gt;
input firstName&lt;br /&gt;
output firstName lastName&lt;br /&gt;
Stop&lt;br /&gt;
&lt;br /&gt;
This is better, but I think we can do even better. Here is the Flowchart and Psuedocode for a simple answer to that problem.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2LJeFyti-xc5A_9_i3i_8DEl0tsnUEUZo8D6bI8JHh0OSb-CMhr3Fcs_J88shT1xTXsbMZusOXyF6dQHlmd1fmxnc_GFwhJtDqgRRlAxEIH91WpxWscWq9OqfiTgqhwhPjXSUV59uHgOR/s1600/NameFlowchart.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2LJeFyti-xc5A_9_i3i_8DEl0tsnUEUZo8D6bI8JHh0OSb-CMhr3Fcs_J88shT1xTXsbMZusOXyF6dQHlmd1fmxnc_GFwhJtDqgRRlAxEIH91WpxWscWq9OqfiTgqhwhPjXSUV59uHgOR/s320/NameFlowchart.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Start&lt;br /&gt;
output &quot;What is your Last Name? &quot;&lt;br /&gt;
input lastName&lt;br /&gt;
output &quot;What is your First Name? &quot;&lt;br /&gt;
input firstName&lt;br /&gt;
output &quot;Is your name &quot; firstName lastName ?&lt;br /&gt;
Stop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
And finally in Python:&lt;br /&gt;
&lt;br /&gt;
##This program asks for Last Name, then First Name and then gives&lt;br /&gt;
##First and Last name in that order.&lt;br /&gt;
lastName = input(&quot;What is your Last Name?&quot;)&lt;br /&gt;
firstName = input(&quot;What is your First Name?&quot;)&lt;br /&gt;
print(&quot;Is your name&quot; , firstName , lastName ,&quot;?&quot;)&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;i&gt;*Note - Apparently raw_input() has been disabled for Python V3.0 (I have updated my code to reflect this).&amp;nbsp;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;i&gt;&lt;b&gt;**Edit** Thanks to bernd-petersohn. Here is his Python3 code:&lt;/b&gt;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;i&gt;&lt;b&gt; &lt;/b&gt;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
#!/usr/bin/python3&lt;br /&gt;
lastName = input(&quot;What is your Last Name? &quot;)&lt;br /&gt;
firstName = input(&quot;What is your First Name? &quot;)&lt;br /&gt;
print(&quot;Is your name {0} {1}?&quot;.format(firstName, lastName)) &lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;i&gt;&lt;b&gt; &lt;/b&gt;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
We still do not act on our data or have decisions, but you can input some data, the data is saved into variables, and the data is then output for your viewing pleasure. His next assignment gets much more difficult and I&#39;ll pose the question to you now to think on it... How would you design a program that finds and outputs the 1000&lt;sup&gt;th&lt;/sup&gt; prime number?</content><link rel='replies' type='application/atom+xml' href='http://geekspot-101.blogspot.com/feeds/7402123211655626478/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://geekspot-101.blogspot.com/2010/09/input-and-output-in-python.html#comment-form' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9066631589719297739/posts/default/7402123211655626478'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9066631589719297739/posts/default/7402123211655626478'/><link rel='alternate' type='text/html' href='http://geekspot-101.blogspot.com/2010/09/input-and-output-in-python.html' title='Input and Output in Python'/><author><name>Geek Spot 101</name><uri>http://www.blogger.com/profile/09401800505792806961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2LJeFyti-xc5A_9_i3i_8DEl0tsnUEUZo8D6bI8JHh0OSb-CMhr3Fcs_J88shT1xTXsbMZusOXyF6dQHlmd1fmxnc_GFwhJtDqgRRlAxEIH91WpxWscWq9OqfiTgqhwhPjXSUV59uHgOR/s72-c/NameFlowchart.jpg" height="72" width="72"/><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9066631589719297739.post-2260671403711553543</id><published>2010-09-10T04:14:00.000-07:00</published><updated>2010-09-10T04:14:29.447-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="beginning programming"/><category scheme="http://www.blogger.com/atom/ns#" term="float"/><category scheme="http://www.blogger.com/atom/ns#" term="int"/><category scheme="http://www.blogger.com/atom/ns#" term="integer"/><category scheme="http://www.blogger.com/atom/ns#" term="operand"/><category scheme="http://www.blogger.com/atom/ns#" term="operator"/><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><category scheme="http://www.blogger.com/atom/ns#" term="str"/><category scheme="http://www.blogger.com/atom/ns#" term="string"/><title type='text'>Operators, Operands, and Hello, World!</title><content type='html'>Good morning! I couldn&#39;t sleep so I&#39;m going through my Python tutorial before work. This morning we&#39;ll talk about manipulating variables. We used operators and operands yesterday, but I did not explain them. &lt;b&gt;Operators&lt;/b&gt; are symbols, like + and - that manipulate data. The data being manipulated is the &lt;b&gt;operand.&lt;/b&gt; So in the statement:&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;x*3&lt;br /&gt;
&lt;br /&gt;
We are multiplying the variable x (The value of a variable is substituted prior to evaluation by the computer) by 3. 3 and x are operands and * is the operator.&amp;nbsp; You can remember this easily by remember the operator of a piece of machinery is the person doing the work. In this case the * is doing the work on the two operands. The following are legal operators:&lt;br /&gt;
&lt;div style=&quot;background-color: white; color: blue; font-family: Times,&amp;quot;Times New Roman&amp;quot;,serif; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;background-color: white; color: black; font-family: Times,&amp;quot;Times New Roman&amp;quot;,serif; text-align: left;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;** = exponent/power&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; color: black; font-family: Times,&amp;quot;Times New Roman&amp;quot;,serif; text-align: left;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;* = Multiply&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; color: black; font-family: Times,&amp;quot;Times New Roman&amp;quot;,serif; text-align: left;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;/ = Divide&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; color: black; font-family: Times,&amp;quot;Times New Roman&amp;quot;,serif; text-align: left;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;+ = Plus&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; color: black; font-family: Times,&amp;quot;Times New Roman&amp;quot;,serif; text-align: left;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;- = Minus&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
Another operator we have used already is the &lt;b&gt;assignment operator&lt;/b&gt; or =. Using = assigns the value on the right to the variable on the left. It is similar but different from the equals sign which we will go over later. First let&#39;s remember the different &lt;b&gt;types&lt;/b&gt; we have gone over (int, float) and let&#39;s add another one &#39;str.&#39; Str, or string, types are strings of characters such as &quot;Hello, World.&quot; The &quot;Hello, World&quot; program is a popular first program and so we can use it today to create our first saved program while learning about strings. &lt;br /&gt;
&lt;br /&gt;
First open IDLE (Python GUI). Select File&amp;gt;New Window. A new window with a text editor pops up and here we can write our program.&lt;br /&gt;
&lt;br /&gt;
##This is a Hello, World! program.&lt;br /&gt;
##It prints &quot;Hello, World!&quot; on the screen.&lt;br /&gt;
print &quot;Hello, World!&quot;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;*Note - Remember the # is the comment designator and is not necessary, but a tip for later when writing longer more complex programs is to always include good notes in your program. You can include these comments for your own benefit, put comments of your own or simply start with print.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;Select File&amp;gt;Save&amp;gt;&amp;gt; HelloWorld.py (or any name followed by the .py extension) &amp;gt;Save. Now, let&#39;s run our program! Do this by selecting Run&amp;gt;Run Module, or pressing &lt;b&gt;F5&lt;/b&gt;. If you have made changes it will let you know you need to save it to run it. When you click Run Module a Python Shell will pop up if you didn&#39;t have one up already and you should see this:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLD3nUnM7d0h-L0sB2GJPaC0jSX5mqmyEHJh4pIRlg6CnTRcDtAeacLBYAAa-s32WMowDtto-KPZtcKsyHwFMX1tc3qZGzftrQOcCFOYBtff6wmRWCXAIbFN9xDwSdd6h0eJK96ftroOzV/s1600/HelloWorld.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;125&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLD3nUnM7d0h-L0sB2GJPaC0jSX5mqmyEHJh4pIRlg6CnTRcDtAeacLBYAAa-s32WMowDtto-KPZtcKsyHwFMX1tc3qZGzftrQOcCFOYBtff6wmRWCXAIbFN9xDwSdd6h0eJK96ftroOzV/s400/HelloWorld.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Hello, World!&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&amp;nbsp;&lt;/span&gt; &lt;/span&gt;&lt;br /&gt;
You now have a program you can run over and over again as long as you want! It doesn&#39;t do a whole lot, but it&#39;s all yours. Hope everyone has a great Friday!</content><link rel='replies' type='application/atom+xml' href='http://geekspot-101.blogspot.com/feeds/2260671403711553543/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://geekspot-101.blogspot.com/2010/09/operators-operands-and-hello-world.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9066631589719297739/posts/default/2260671403711553543'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9066631589719297739/posts/default/2260671403711553543'/><link rel='alternate' type='text/html' href='http://geekspot-101.blogspot.com/2010/09/operators-operands-and-hello-world.html' title='Operators, Operands, and Hello, World!'/><author><name>Geek Spot 101</name><uri>http://www.blogger.com/profile/09401800505792806961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLD3nUnM7d0h-L0sB2GJPaC0jSX5mqmyEHJh4pIRlg6CnTRcDtAeacLBYAAa-s32WMowDtto-KPZtcKsyHwFMX1tc3qZGzftrQOcCFOYBtff6wmRWCXAIbFN9xDwSdd6h0eJK96ftroOzV/s72-c/HelloWorld.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9066631589719297739.post-7459180981067667056</id><published>2010-09-09T17:56:00.000-07:00</published><updated>2010-09-10T03:36:42.936-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="beginning programming"/><category scheme="http://www.blogger.com/atom/ns#" term="float"/><category scheme="http://www.blogger.com/atom/ns#" term="floating point"/><category scheme="http://www.blogger.com/atom/ns#" term="int"/><category scheme="http://www.blogger.com/atom/ns#" term="integer"/><category scheme="http://www.blogger.com/atom/ns#" term="programming"/><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><category scheme="http://www.blogger.com/atom/ns#" term="variables"/><title type='text'>Declaring Variables w/ Python</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6xopQvlkhb92yzM3eb_7MJuj_Eyi7H_dETANMzCcZKHot-B5pQ_O8SazIGYibipaQDP00bz5EPc1aUmgRjP63oHvFKKsgthBDM3ystU_vLu8xPMrunH7Lk7-Kyk8y4L8JBqn5QyTueH-a/s1600/python.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6xopQvlkhb92yzM3eb_7MJuj_Eyi7H_dETANMzCcZKHot-B5pQ_O8SazIGYibipaQDP00bz5EPc1aUmgRjP63oHvFKKsgthBDM3ystU_vLu8xPMrunH7Lk7-Kyk8y4L8JBqn5QyTueH-a/s320/python.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;Hello again! It&#39;s Thursday, which is one of my favorite days, if only because it means Friday is almost here! I&#39;d like to end my Thursday with a lesson on variables. Before we get started however I thought it would be a good learning experience, for myself and perhaps others, to do my logic work in psedocode, and actual code (and perhaps a flowchart). For the &quot;real code&quot; I&#39;m going to use Python.&lt;br /&gt;
&lt;br /&gt;
There are a few really good links for help on Python programming. One is from the Python website itself &lt;a href=&quot;http://docs.python.org/tutorial/index.html&quot;&gt;here.&lt;/a&gt;&lt;b&gt; &lt;/b&gt;As well as from the &lt;a href=&quot;http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-00-introduction-to-computer-science-and-programming-fall-2008/&quot;&gt;Introduction to Computer Science and Programming&lt;/a&gt; course on MIT&#39;s OpenCourseWare (OCW) website. The MIT OCW website has many classes and programs you can go through free of charge and look very interesting. Harvard also has a similar setup &lt;a href=&quot;http://academicearth.org/courses/introduction-to-computer-science-i&quot;&gt;here&lt;/a&gt; and it looks like they use C whereas MIT is using Python in instruction.&amp;nbsp;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt; &lt;/b&gt;&lt;br /&gt;
If you want to follow along with me you should go to the Python website and &lt;a href=&quot;http://python.org/download/releases/2.7/&quot;&gt;download version 2.7&lt;/a&gt; If you prefer to use 3.0 that&#39;s fine but 2.7 is backward and forward compatible whereas 3.0 has gotten rid of some things that I may be using since I&#39;m following the MIT OCW course, recorded in 2008.&lt;br /&gt;
&lt;br /&gt;
Once you&#39;ve installed Python, bring up the Python Shell also called IDLE (Python GUI) which should look like this:&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgmX9cJFLFiY_66Ql2K3qeEj4yJY58aqB6PgcdWgSvyGvRDlfmEbWI1f68GktZNLeElSYYp5Cztt2LPbRoI8WAvDfOfHexWFqutY8ZaGeCXfnf57bmUp58pSJ5_F_2aHN0-Z75ree3sL4UW/s1600/PythonShell.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgmX9cJFLFiY_66Ql2K3qeEj4yJY58aqB6PgcdWgSvyGvRDlfmEbWI1f68GktZNLeElSYYp5Cztt2LPbRoI8WAvDfOfHexWFqutY8ZaGeCXfnf57bmUp58pSJ5_F_2aHN0-Z75ree3sL4UW/s400/PythonShell.jpg&quot; width=&quot;382&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;IDLE (Python GUI) / Python Shell&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;From here you can input all the commands which I will preface with &amp;gt;&amp;gt;&amp;gt; to look the same as the Python Shell.&lt;br /&gt;
&lt;br /&gt;
Now, onto the lesson: &lt;b&gt;Variables are memory locations, the contents of which may vary throughout the program.&lt;/b&gt; For example:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;gt;&amp;gt;&amp;gt;numberOne = 1 #Hit Return&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;*Note - # is Python for comment. Meaning, typing it would not hurt, but does nothing for you. I am only letting you know here to hit return to enter 1 as the value for numberOne.&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
This sets a memory location, nicknamed &quot;numberOne&quot; to the value of 1. To write this in pseudocode you can write it the same &quot;numberOne = 1&quot; since this is a simple statement, or to be more clear:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set numberOne = 1&lt;br /&gt;
&lt;br /&gt;
Remember I said variables can change. We can now type in the Shell:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;gt;&amp;gt;&amp;gt;numberOne = numberOne + 1&lt;br /&gt;
&lt;br /&gt;
This may look weird, but it should be simple enough to see what is happening. We are taking numberOne and setting it equal to numberOne + 1, or just adding one to it. If you type:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;gt;&amp;gt;&amp;gt;print numberOne&lt;br /&gt;
&lt;br /&gt;
You should now get the result: 2.&lt;br /&gt;
&lt;br /&gt;
The last thing I want to mention briefly is the data type of this number:&lt;br /&gt;
&lt;br /&gt;
2&lt;br /&gt;
&lt;br /&gt;
The number 2 is an &lt;b&gt;integer or int&lt;/b&gt;, and has no decimal value. In Python, and most other programming languages, this is important. The type is decided when you initialized the variable. To make this make sense try typing 7/2 into the Python Shell and hit return. Notice &lt;i&gt;the answer is not 3.5 but 3!&lt;/i&gt; An integer has no decimal value, and your attempt at dividing, which would create a decimal is ignored and it throws out the remainder.&lt;br /&gt;
&lt;br /&gt;
If you are writing a program that requires the decimal values, you can use what is called a &lt;b&gt;floating point or float.&lt;/b&gt; To make it a float, just type 7.0 (the .0 part making it float) and divide that by 2. What do you see? 3.5!&lt;br /&gt;
&lt;br /&gt;
Be careful when writing your programs that you keep track of this. There are ways in many programming languages to change the type, but doing so unnecessarily can cause leaks and bugs in your program.&lt;br /&gt;
&lt;br /&gt;
Lastly, a neat trick to see the remainder of the integer division is by using the % sign. Using % divides one side by the other and gives the remainder.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;gt;&amp;gt;&amp;gt;7%2&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;1&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Tomorrow I&#39;ll try and post something a little more... interesting to program. Until then enjoy the tutorials and let me know what you think!</content><link rel='replies' type='application/atom+xml' href='http://geekspot-101.blogspot.com/feeds/7459180981067667056/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://geekspot-101.blogspot.com/2010/09/declaring-variables-w-python.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9066631589719297739/posts/default/7459180981067667056'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9066631589719297739/posts/default/7459180981067667056'/><link rel='alternate' type='text/html' href='http://geekspot-101.blogspot.com/2010/09/declaring-variables-w-python.html' title='Declaring Variables w/ Python'/><author><name>Geek Spot 101</name><uri>http://www.blogger.com/profile/09401800505792806961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6xopQvlkhb92yzM3eb_7MJuj_Eyi7H_dETANMzCcZKHot-B5pQ_O8SazIGYibipaQDP00bz5EPc1aUmgRjP63oHvFKKsgthBDM3ystU_vLu8xPMrunH7Lk7-Kyk8y4L8JBqn5QyTueH-a/s72-c/python.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9066631589719297739.post-3280426015445559210</id><published>2010-09-08T20:23:00.000-07:00</published><updated>2010-09-08T20:23:18.081-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="android"/><category scheme="http://www.blogger.com/atom/ns#" term="beginner"/><category scheme="http://www.blogger.com/atom/ns#" term="beginning programming"/><category scheme="http://www.blogger.com/atom/ns#" term="eclipse"/><category scheme="http://www.blogger.com/atom/ns#" term="IDE"/><category scheme="http://www.blogger.com/atom/ns#" term="integrated development envioronment"/><category scheme="http://www.blogger.com/atom/ns#" term="visual studio express"/><title type='text'>Integrated Development Envioronments</title><content type='html'>When you&#39;re first getting into programming you may hear the term &lt;b&gt;integrated development environment (IDE)&lt;/b&gt; and wonder: What is it? and Do I need one?&lt;br /&gt;
&lt;br /&gt;
An IDE is a common toolsuite for programming combining all the necessary tools (editor, compiler, and other programming tools)into one. Many will now help you with your programming guessing at what you are going to type and helping you complete it. Microsoft Visual Studio and Eclipse (Along with a whole lot of others) are popular IDEs that support multiple languages.&lt;br /&gt;
&lt;br /&gt;
Some beginning programming books have you learn programming from a text editor, save the file, put it through a compiler (in a command window) and then run your program (as well in the command window). With the IDE all of that can be done with the click of a button. This makes it much easier to debug and test changes in your program.&lt;br /&gt;
&lt;br /&gt;
If you want to get started, how about trying the C++ guide (a free download) from&lt;a href=&quot;http://msdn.microsoft.com/en-us/beginner/cc305129.aspx&quot;&gt; Microsoft&#39;s Development for Beginners site&lt;/a&gt;. and downloading one of these programs:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEJQx5MpLy5SB-HDwmAFKxssQjXZsOnddRekRFxVO9IiTm389g1gJ4798VXWtSZV1x9wyHisYD8yw4CLsnhLQsYTEQtG9hyezdpqbl0VENXigGwjFtdSJTo-ROYdJG4x5uhXgKAZasaa2o/s1600/visual+studio+express.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEJQx5MpLy5SB-HDwmAFKxssQjXZsOnddRekRFxVO9IiTm389g1gJ4798VXWtSZV1x9wyHisYD8yw4CLsnhLQsYTEQtG9hyezdpqbl0VENXigGwjFtdSJTo-ROYdJG4x5uhXgKAZasaa2o/s320/visual+studio+express.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Visual Studio can be downloaded by language (VisualBasic, C#, or C++) as a &lt;a href=&quot;http://www.microsoft.com/express/Windows/&quot;&gt;free version here&lt;/a&gt;. &lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkJU-LgkFC2UIfOTF7TjF-TwT8pGq40mfIbrKrnD5mty3Jxlh-oU54HjB6-30JvGds0bBe7UDcu1JCjhRyQOYgYe0UUb5N0EIiD0RkzDFyD1omE8ipBdL0JruHP-CeZ8GzEvJhvBHqaag-/s1600/eclipse_logo_3.0.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkJU-LgkFC2UIfOTF7TjF-TwT8pGq40mfIbrKrnD5mty3Jxlh-oU54HjB6-30JvGds0bBe7UDcu1JCjhRyQOYgYe0UUb5N0EIiD0RkzDFyD1omE8ipBdL0JruHP-CeZ8GzEvJhvBHqaag-/s320/eclipse_logo_3.0.gif&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Eclipse is a free open-source program available &lt;a href=&quot;http://www.eclipse.org/downloads/&quot;&gt;here&lt;/a&gt;. It is written primarily in Java and is built by the non-profit Eclipse Foundation. Eclipse is also the development environment suggested by Android for programming Android applications. I&#39;ve tried some basic programming in both Visual Studio and Eclipse and personally I like Eclipse better. What do you guys think?</content><link rel='replies' type='application/atom+xml' href='http://geekspot-101.blogspot.com/feeds/3280426015445559210/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://geekspot-101.blogspot.com/2010/09/integrated-development-envioronments.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9066631589719297739/posts/default/3280426015445559210'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9066631589719297739/posts/default/3280426015445559210'/><link rel='alternate' type='text/html' href='http://geekspot-101.blogspot.com/2010/09/integrated-development-envioronments.html' title='Integrated Development Envioronments'/><author><name>Geek Spot 101</name><uri>http://www.blogger.com/profile/09401800505792806961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEJQx5MpLy5SB-HDwmAFKxssQjXZsOnddRekRFxVO9IiTm389g1gJ4798VXWtSZV1x9wyHisYD8yw4CLsnhLQsYTEQtG9hyezdpqbl0VENXigGwjFtdSJTo-ROYdJG4x5uhXgKAZasaa2o/s72-c/visual+studio+express.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9066631589719297739.post-9011730001123588599</id><published>2010-09-07T16:39:00.000-07:00</published><updated>2010-09-07T16:39:06.536-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="computer logic"/><category scheme="http://www.blogger.com/atom/ns#" term="computer program design"/><category scheme="http://www.blogger.com/atom/ns#" term="programing"/><category scheme="http://www.blogger.com/atom/ns#" term="programming logic"/><category scheme="http://www.blogger.com/atom/ns#" term="psuedocode"/><title type='text'>Introduction to Pseudocode</title><content type='html'>First off, what is pseudocode? It is merely a combination of: pseudo (meaning almost, approaching, or trying to be) and code (the language you are writing in; the set of instructions in a program). &lt;b&gt;It is an informal written representation of your program.&lt;/b&gt; In pseudocode you don&#39;t need to follow syntax requirements, and really as long as it makes sense to you it doesn&#39;t matter how you do it. Here are a few guidelines you can follow however to get the most use out of your pseudocode:&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Begin and end your code with terminal statements (i.e. begin,end,start,stop).&lt;/li&gt;
&lt;li&gt;Don&#39;t use terminal statements if you don&#39;t like them. &lt;/li&gt;
&lt;li&gt;Use indentation freely to increase readability.&lt;/li&gt;
&lt;li&gt;Don&#39;t overuse indentation.&lt;/li&gt;
&lt;li&gt;Make it make sense to you.&lt;/li&gt;
&lt;/ol&gt;Basically it all boils down to, how do you want to do it? As you learn more about if then, while, do while, statements it becomes more clear what to do. Here is a short example using the same program in my &lt;a href=&quot;http://geekspot-101.blogspot.com/2010/09/flowchart.html&quot;&gt;Flowchart&lt;/a&gt; introduction.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; start&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; input phoneNumber&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; call phoneNumber&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if phoneAnswered = no&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; call phoneNumber&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else output &quot;Hello&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Does anyone else have some tips or pointers when using pseudocode?&lt;br /&gt;
&lt;ol&gt;&lt;/ol&gt;</content><link rel='replies' type='application/atom+xml' href='http://geekspot-101.blogspot.com/feeds/9011730001123588599/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://geekspot-101.blogspot.com/2010/09/introduction-to-pseudocode.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9066631589719297739/posts/default/9011730001123588599'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9066631589719297739/posts/default/9011730001123588599'/><link rel='alternate' type='text/html' href='http://geekspot-101.blogspot.com/2010/09/introduction-to-pseudocode.html' title='Introduction to Pseudocode'/><author><name>Geek Spot 101</name><uri>http://www.blogger.com/profile/09401800505792806961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9066631589719297739.post-799345047023662724</id><published>2010-09-06T14:11:00.000-07:00</published><updated>2010-09-07T18:23:53.470-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="computer logic"/><category scheme="http://www.blogger.com/atom/ns#" term="computer program design"/><category scheme="http://www.blogger.com/atom/ns#" term="flowchart"/><title type='text'>Flowchart</title><content type='html'>&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;float: left; margin-right: 1em; text-align: left;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a alt=&quot;flowchart example&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhExTOKrzPwR8d4601DyUKufi_W8oWc73BOIJNK0O0IJ1BQrzFhI-W4uQFM1-TZ3tBPhISbdrB9P6etL7CK3PJDRG0mM73wSt79PZrzTZ2OPId87kYqmX3o77AMlS2fSiH6ywybsJ4p-5oT/s1600/flowchart.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhExTOKrzPwR8d4601DyUKufi_W8oWc73BOIJNK0O0IJ1BQrzFhI-W4uQFM1-TZ3tBPhISbdrB9P6etL7CK3PJDRG0mM73wSt79PZrzTZ2OPId87kYqmX3o77AMlS2fSiH6ywybsJ4p-5oT/s640/flowchart.jpg&quot; width=&quot;440&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Flowchart Example&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;Here is a simplified example of a flowchart for a program that calls a number for you until someone answers and says &quot;Hello&quot; for you. You&#39;ll notice at the beginning and the end there is the racetrack shaped symbol:&lt;br /&gt;
&lt;br /&gt;
&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;float: left; margin-right: 1em; text-align: left;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a alt=&quot;flowchart terminal example&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsOaUi_ACFb_m-KgcSJqMw_thMrvpaxT2ARIhFACSCP-J4m8akmmnQtBCGAKGMSxn2YhwnIWKq2UE4cFGG2iwERZc3VtZFyoouJDZSh51unM30G8pIs7f_uHIrvfi8ZKD9ql2GQ3kdLD7v/s1600/terminal.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsOaUi_ACFb_m-KgcSJqMw_thMrvpaxT2ARIhFACSCP-J4m8akmmnQtBCGAKGMSxn2YhwnIWKq2UE4cFGG2iwERZc3VtZFyoouJDZSh51unM30G8pIs7f_uHIrvfi8ZKD9ql2GQ3kdLD7v/s320/terminal.jpg&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Terminal Symbol&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;br /&gt;
This is called the &lt;b&gt;terminal&lt;/b&gt; symbol and denotes the beginning and end of a program.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After the terminal symbol you should notice the parallelogram shape:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;float: left; margin-right: 1em; text-align: left;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a alt=&quot;input output symbol example&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEia-AfGZZXJ4Gi05eiW746WxkbNxCk8ve__nX5jIDz91k811h0jV40GUjE9mw3Ju3lvwsOPuq_rg5sY24meRTZyWgHD86qpqk8IsHVOzN48O287z69NaQwCPJDU9naorIW4tdFzhkfeZ1xK/s1600/iosymbol.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEia-AfGZZXJ4Gi05eiW746WxkbNxCk8ve__nX5jIDz91k811h0jV40GUjE9mw3Ju3lvwsOPuq_rg5sY24meRTZyWgHD86qpqk8IsHVOzN48O287z69NaQwCPJDU9naorIW4tdFzhkfeZ1xK/s320/iosymbol.jpg&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Input/Ouput Symbol&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
This is the &lt;b&gt;input/ouput&lt;/b&gt; symbol. Anytime a new constant or variable needs to be input or output, use this symbol. Here we use it to input phoneNumber and ouput the phrase &quot;Hello&quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Next in the flowchart is the plain rectangle shape:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;float: left; margin-right: 1em; text-align: left;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a alt=&quot;processing symbol example&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghPGcqK5tQaE-MuGGJClXhaa6FUJ-9uBAofk9Gf-UPuJZdap6Bfam77uiqXAMwQllU6MeQErTKYHFEb-Ig-7nR1gL8A-PLY5xQ78gyV2D1vluqfv0Qp1Q3uGXiAc4ZoVAh2M7ElHPZ-Wbm/s1600/processingsymbol.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghPGcqK5tQaE-MuGGJClXhaa6FUJ-9uBAofk9Gf-UPuJZdap6Bfam77uiqXAMwQllU6MeQErTKYHFEb-Ig-7nR1gL8A-PLY5xQ78gyV2D1vluqfv0Qp1Q3uGXiAc4ZoVAh2M7ElHPZ-Wbm/s320/processingsymbol.jpg&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Processing Symbol&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
Here is the &lt;b&gt;processing&lt;/b&gt; symbol. This is where something is done, input is used, and/or data is manipulated. Here we use it to call the input phoneNumber.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The final shape looks like a diamond:&lt;br /&gt;
&lt;br /&gt;
&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;float: left; margin-right: 1em; text-align: left;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a alt=&quot;decision symbol example&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigVAC6lPKi7J1vY6NgD9nTK5-7ODie69HwUGKqceg5Aoh7xWVtTBzMg8aOZrZptP1C4p5XTtQkcKMXw6fmWDUltI66K6KgLFlTf7aKHgkS7R5LzBzMOr1gpbEoVX5Lv2ycf-DZQc7wZXxD/s1600/decisionsymbol.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigVAC6lPKi7J1vY6NgD9nTK5-7ODie69HwUGKqceg5Aoh7xWVtTBzMg8aOZrZptP1C4p5XTtQkcKMXw6fmWDUltI66K6KgLFlTf7aKHgkS7R5LzBzMOr1gpbEoVX5Lv2ycf-DZQc7wZXxD/s320/decisionsymbol.jpg&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Decision Symbol&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
The diamond shape denotes the &lt;b&gt;decision&lt;/b&gt; symbol. Here the computer checks to see if a statement is true or false and acts on that truth value as you have determined. Here we have said &lt;b&gt;if&lt;/b&gt; the phone is not answered &lt;b&gt;then&lt;/b&gt; call again. If it is, then the program finishes by saying &quot;Hello&quot; and ending.&lt;br /&gt;
&lt;br /&gt;
Note: The does not equal could have also been written as !=, &amp;lt;&amp;gt;, or simply &quot;does not equal&quot;. This is your preference. Sometimes using does not equal makes it easier to understand what the program, rather than using &quot;= no.&quot;&lt;br /&gt;
&lt;br /&gt;
Note 2: Yes and no can be denoted as 1 and 0 respectively.</content><link rel='replies' type='application/atom+xml' href='http://geekspot-101.blogspot.com/feeds/799345047023662724/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://geekspot-101.blogspot.com/2010/09/flowchart.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9066631589719297739/posts/default/799345047023662724'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9066631589719297739/posts/default/799345047023662724'/><link rel='alternate' type='text/html' href='http://geekspot-101.blogspot.com/2010/09/flowchart.html' title='Flowchart'/><author><name>Geek Spot 101</name><uri>http://www.blogger.com/profile/09401800505792806961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhExTOKrzPwR8d4601DyUKufi_W8oWc73BOIJNK0O0IJ1BQrzFhI-W4uQFM1-TZ3tBPhISbdrB9P6etL7CK3PJDRG0mM73wSt79PZrzTZ2OPId87kYqmX3o77AMlS2fSiH6ywybsJ4p-5oT/s72-c/flowchart.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9066631589719297739.post-255330240142351984</id><published>2010-09-02T11:53:00.000-07:00</published><updated>2010-09-02T11:53:11.787-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="computer logic"/><category scheme="http://www.blogger.com/atom/ns#" term="computer program design"/><category scheme="http://www.blogger.com/atom/ns#" term="if"/><category scheme="http://www.blogger.com/atom/ns#" term="if then"/><category scheme="http://www.blogger.com/atom/ns#" term="programming"/><category scheme="http://www.blogger.com/atom/ns#" term="programming logic"/><category scheme="http://www.blogger.com/atom/ns#" term="repetition"/><category scheme="http://www.blogger.com/atom/ns#" term="selection"/><category scheme="http://www.blogger.com/atom/ns#" term="sequence"/><category scheme="http://www.blogger.com/atom/ns#" term="structured programming"/><category scheme="http://www.blogger.com/atom/ns#" term="then"/><title type='text'>Structured Programming</title><content type='html'>Structured programming states that any program can be created through the use of three procedures: sequence, selection, and repetition.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;1. Sequence:&lt;/b&gt; One thing happens, then another, then another... Get bowl, Place bowl, fill bowl with 1 cup cereal, put 1/4 cup milk in bowl, scoop cereal, eat cereal. To make this work each process must be done in order, else you may be eating your cereal off of the table.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;2. Selection:&lt;/b&gt; Selection is the decision portion of your program. If you don&#39;t have a bowl in front of you, then grab a bowl. If you have a bowl to put on the table, then put it on the table. If there is no cereal in your bowl, then put cereal in the bowl... by now I&#39;m sure you get the gist.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;3. Repetition:&lt;/b&gt; Repetition tells the program to do something again and again as needed (or specified by you, the programmer). At the end you can add a selection, if hungry repeat. You already have a bowl, so the program continues to the next step. The bowl is filled (because you have only taken one bite), you continue until you are either no longer hungry or the bowl is empty, in which case the bowl would refill and you would eat until no longer hungry.&lt;br /&gt;
&lt;br /&gt;
Anything else you want to do can be done by placing one or more of these within themselves (i.e. nesting statements) but every programming element is a composition of one or more of these three.&lt;br /&gt;
&lt;br /&gt;
The examples given are not necessarily complete, there are practically an infinite number of steps that could be inserted (breathing between bites, wait time between bites, chewing, swallowing, etc. etc. etc.), but you should have a general understanding of structured programming.</content><link rel='replies' type='application/atom+xml' href='http://geekspot-101.blogspot.com/feeds/255330240142351984/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://geekspot-101.blogspot.com/2010/09/structured-programming.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9066631589719297739/posts/default/255330240142351984'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9066631589719297739/posts/default/255330240142351984'/><link rel='alternate' type='text/html' href='http://geekspot-101.blogspot.com/2010/09/structured-programming.html' title='Structured Programming'/><author><name>Geek Spot 101</name><uri>http://www.blogger.com/profile/09401800505792806961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9066631589719297739.post-8783553083843076527</id><published>2010-08-31T17:14:00.000-07:00</published><updated>2010-09-07T18:10:56.545-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="computer program design"/><category scheme="http://www.blogger.com/atom/ns#" term="computer science"/><category scheme="http://www.blogger.com/atom/ns#" term="computers"/><category scheme="http://www.blogger.com/atom/ns#" term="design life cycle"/><category scheme="http://www.blogger.com/atom/ns#" term="planning"/><category scheme="http://www.blogger.com/atom/ns#" term="program design"/><category scheme="http://www.blogger.com/atom/ns#" term="programs"/><title type='text'>An introduction to Computer Program Design</title><content type='html'>The computer program design life cycle is simple, yet probably not something one would think of when first learning programming. Remember, major programming is done in teams of people working to create a product for an end user.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;1. Understand:&lt;/b&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; -You must understand what is required of you, where the program is going and what your part in all of this is.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;2. Plan:&lt;/b&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; -Write it down! Whether you use &lt;a href=&quot;http://geekspot-101.blogspot.com/2010/09/flowchart.html&quot;&gt;flowcharts&lt;/a&gt; or &lt;a href=&quot;http://geekspot-101.blogspot.com/2010/09/introduction-to-pseudocode.html&quot;&gt;psuedocode&lt;/a&gt; you need to have a plan before you start programming.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;3. Code:&lt;/b&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; -This is where most people want to start, but it is important to follow through with the first steps. This is true in more than just programming. Planning will save you headaches here!&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;4. Compile:&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp; &lt;/b&gt;- Here is where you use a compiler to translate your code to machine language. If you have followed proper programming protocol (syntax) you now have a working computer program!&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;5. Test:&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp; &lt;/b&gt;- You thought you were done there??? Not quite yet! Now it&#39;s time to test the product, fix any bugs, and if necessary go back through the previous steps until you have a workable bug free (to the greatest extent possible, all sizable programs will have bugs) program.&lt;br /&gt;
&lt;b&gt;&amp;nbsp; &lt;/b&gt;&lt;br /&gt;
&lt;b&gt;6. Launch:&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp; &lt;/b&gt;- Your program finally gets an audience. Months of staring at a screen and 4 cases of Red Bull later and you have the satisfaction of watching your program in action. Ahhh yesss....&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;7. Maintain:&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp; &lt;/b&gt;- If only that were it. Many customers will want support, updates will have to be put out as new bugs are found. This step lasts as long as there is a reasonable need and as long as the program&#39;s design is still reasonably usable. As new technology emerges your program may (will) become obsolete and need to be brought into the new generation.&lt;b&gt; And the cycle begins anew...&lt;/b&gt;</content><link rel='replies' type='application/atom+xml' href='http://geekspot-101.blogspot.com/feeds/8783553083843076527/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://geekspot-101.blogspot.com/2010/08/introduction-to-program-design.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9066631589719297739/posts/default/8783553083843076527'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9066631589719297739/posts/default/8783553083843076527'/><link rel='alternate' type='text/html' href='http://geekspot-101.blogspot.com/2010/08/introduction-to-program-design.html' title='An introduction to Computer Program Design'/><author><name>Geek Spot 101</name><uri>http://www.blogger.com/profile/09401800505792806961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9066631589719297739.post-5608425048245328840</id><published>2010-08-31T16:41:00.000-07:00</published><updated>2010-08-31T16:41:59.254-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="computer logic"/><category scheme="http://www.blogger.com/atom/ns#" term="computer science"/><category scheme="http://www.blogger.com/atom/ns#" term="program design"/><category scheme="http://www.blogger.com/atom/ns#" term="programming"/><title type='text'>An introduction to Computer Logic</title><content type='html'>Logic is defined as the study of arguments. In logic you are finding the proper way to make a statement that is understandable and is a true statement. A computer program is exactly that, a series of arguments, all with a value of true or false. This makes sense when you think that computer code, binary, is a string of ones and zeros. The computer circuit can read the presence of electrical current as a 1 and absence as a 0. Even the most complex programs can be broken down into strings of true and false.</content><link rel='replies' type='application/atom+xml' href='http://geekspot-101.blogspot.com/feeds/5608425048245328840/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://geekspot-101.blogspot.com/2010/08/introduction-to-computer-logic.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9066631589719297739/posts/default/5608425048245328840'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9066631589719297739/posts/default/5608425048245328840'/><link rel='alternate' type='text/html' href='http://geekspot-101.blogspot.com/2010/08/introduction-to-computer-logic.html' title='An introduction to Computer Logic'/><author><name>Geek Spot 101</name><uri>http://www.blogger.com/profile/09401800505792806961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9066631589719297739.post-4935070450691511164</id><published>2010-08-31T15:33:00.000-07:00</published><updated>2010-09-02T16:27:42.611-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="beginner"/><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="C++"/><category scheme="http://www.blogger.com/atom/ns#" term="computer"/><category scheme="http://www.blogger.com/atom/ns#" term="computer science"/><category scheme="http://www.blogger.com/atom/ns#" term="development"/><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><category scheme="http://www.blogger.com/atom/ns#" term="learn"/><category scheme="http://www.blogger.com/atom/ns#" term="logic"/><category scheme="http://www.blogger.com/atom/ns#" term="program"/><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><category scheme="http://www.blogger.com/atom/ns#" term="software"/><title type='text'>Learning to Program!</title><content type='html'>Computer programming has always been a fascination of mine. A dream always just beyond my reach due (mostly) to laziness. Learning to program takes time, persistence, and many long hours in front of a computer. So lets get into it.&lt;br /&gt;
&lt;br /&gt;
What do you need to begin programming?&lt;br /&gt;
&lt;br /&gt;
First you should have a solid grasp of &lt;a href=&quot;http://geekspot-101.blogspot.com/2010/08/introduction-to-computer-logic.html&quot;&gt;computer logic&lt;/a&gt; and &lt;a href=&quot;http://geekspot-101.blogspot.com/2010/08/introduction-to-program-design.html&quot;&gt;program design&lt;/a&gt;. As a beginner programmer most colleges require you take a logic class either before or as you take your first computer science courses. &lt;a href=&quot;http://geekspot-101.blogspot.com/2010/09/structured-programming.html&quot;&gt;Structured programming&lt;/a&gt; takes you through the software development process and helps the programmer design code that can be easily read by himself and others. Why this is important will become clear as we go along. Interestingly, the hardest part is designing the logic, or figuring the &quot;how&quot; of the program. After that you only have to translate that logic into computer language.&lt;br /&gt;
&lt;br /&gt;
Computer language is achieved more simply by using a programming language. Though arcane, programming language is not computer language. Computer language is a series of 1&#39;s and 0&#39;s or binary bits. Programming languages in human language (or close to it), and are structured to be transformed into computer language by the compiler as long as proper syntax is used. Some programming languages include, Java, C, C++, C#, Python, and many others.</content><link rel='replies' type='application/atom+xml' href='http://geekspot-101.blogspot.com/feeds/4935070450691511164/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://geekspot-101.blogspot.com/2010/08/learning-to-program.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9066631589719297739/posts/default/4935070450691511164'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9066631589719297739/posts/default/4935070450691511164'/><link rel='alternate' type='text/html' href='http://geekspot-101.blogspot.com/2010/08/learning-to-program.html' title='Learning to Program!'/><author><name>Geek Spot 101</name><uri>http://www.blogger.com/profile/09401800505792806961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>