Posts

Showing posts with the label #WhileLoop #Coding

Collatz Hypothesis

Image
Section 3 - Lab 15  Link to Lab File Scenario In 1937, a German mathematician named Lothar Collatz formulated an intriguing hypothesis (it still remains unproven) which can be described in the following way: take any non-negative and non-zero integer number and name it  c0 ; if it's even, evaluate a new  c0  as  c0 ÷ 2 ; otherwise, if it's odd, evaluate a new  c0  as  3 × c0 + 1 ; if  c0 ≠ 1 , skip to point 2. The hypothesis says that regardless of the initial value of  c0 , it will always go to 1. Of course, it's an extremely complex task to use a computer in order to prove the hypothesis for any natural number (it may even require artificial intelligence), but you can use Python to check some individual numbers. Maybe you'll even find the one which would disprove the hypothesis. Write a program which reads one natural number and executes the above steps as long as  c0  remains different from 1. We also want you to count the ...

Week 3 - Just getting fun!

Image
 Three weeks into the class, and we are now getting into the meat of things I remember how to do in other languages. Loops, variable, etc.  Here is a simple lab I did today.  The secret word to be guessed is "chupacabra".  The user attempts to guess the secret word, and is kept in the loop until they guess it correctly.  I put in a check for an upper or lower case solution.  One the secret word is entered, the loop is broken.

Learn to code, he said!

Image
Having been recently demoted at my place of employment, I decided to follow through on something I very much wanted to do before the demotion.   My first year out of high school was 1983, and I enrolled at the local Community College as a Computer Science Major. I had a great time learning COBOL, Fortran and Pascal, to add to the Basic that I had already taught myself after hours spent in the dark, damp basement of our home.  But like many dreams, this one morphed into another dream which took me down the road of pursuing another passion by going to culinary school.   I've always loved the challenges of writing a fresh piece of code that makes a computer do something, show something or solve a problem. Over the years I've dabbled in Javascript and Excel VBA, and that was about the extent of my "programming". Then I saw an opportunity at the local Vo-Tech to take a class in Python. I did a bit of research and found that Python is a very powerful programming l...