WSQ13 – SciLab

What To Do

Scilab is a great tool that I believe you will find very useful during the rest of your degree programs and beyond. The motivation here is simply to introduce you to the tool. Scilab is open source software and runs on Linux, Mac and Windows

Download the latest version at http://www.scilab.org/download/latest

Please download and “play with” SciLab.

Please follow the tutorial available on their website under Resources->Documentation. Here is the direct link to the tutorial http://www.scilab.org/content/download/849/7901/file/Scilab_beginners.pdf

Page for SciLab to download at https://www.scilab.org

Do NOT panic, there are 33 pages but it will not take you too long to go through it.

What to Submit

As usual, create a blog post explaining what you did, where you found resources (books, videos, web pages, friends) to help you solve this. Remember to put the tag #WSQ13 on your post so our blog hub picks that up.

You should include your code as a link to GitHub.

And of course, leave any questions here as well as asking those questions Twitter #TC1017 so we all see your question posted there.

Feature Image Credit

<a title="In SciLab, you become the scientist..." href="https://flickr.com/photos/mysciencecenter/16362183413">In SciLab, you become the scientist...</a> flickr photo by <a href="https://flickr.com/people/mysciencecenter">The Maryland Science Center</a> shared under a <a href="https://creativecommons.org/licenses/by-nd/2.0/">Creative Commons (BY-ND) license</a> </small>
In SciLab, you become the scientist… flickr photo by The Maryland Science Center shared under a Creative Commons (BY-ND) license

WSQ12 – Estimating e

What To Do

In this assignment you will estimate the mathematical constant e. You should create a function called calculuate_e which receives one parameter called precision that should specify the number of decimal points of accuracy.

You will want to use the infinite series to calculate the value, stopping when the accuracy is reached (previous and current calculation are the same at the specified accuracy).

What to Submit

As usual, create a blog post explaining what you did, where you found resources (books, videos, web pages, friends) to help you solve this. Remember to put the tag #WSQ12 on your post so our blog hub picks that up.

You should include your code as a link to GitHub.

And of course, leave any questions here as well as asking those questions Twitter #TC1017 so we all see your question posted there.

Feature Image Credit

<a title="e" href="https://flickr.com/photos/gailtang/2786292212">e</a> flickr photo by <a href="https://flickr.com/people/gailtang">gail m tang</a> shared under a <a href="https://creativecommons.org/licenses/by-nc-sa/2.0/">Creative Commons (BY-NC-SA) license</a> </small>
e flickr photo by gail m tang shared under a Creative Commons (BY-NC-SA) license

WSQ11 – Go Bananas

What To Do

Write a function called find_bananas which receives a single parameter called filename (a string) and returns a positive integer which is the number of times the word (string) “banana”  (or “BANANA” ) is found in the file. The banana can be any case (‘BaNana’ or ‘BANANA’ or ‘banana’, etc) and they can be “stuck together” like “banAnaBANANA” (that counts as two). Create your own test file (plain text) to check your work.

What to Submit

As usual, create a blog post explaining what you did, where you found resources (books, videos, web pages, friends) to help you solve this. Remember to put the tag #WSQ11 on your post so our blog hub picks that up.

You should include your code as a link to GitHub.

And of course, leave any questions here as well as asking those questions Twitter #TC1017 so we all see your question posted there.

Feature Image Credit

<a title="Colored Bananas" href="https://flickr.com/photos/cleberquadros/3834587963">Colored Bananas</a> flickr photo by <a href="https://flickr.com/people/cleberquadros">Cleber Quadros</a> shared under a <a href="https://creativecommons.org/licenses/by-nc/2.0/">Creative Commons (BY-NC) license</a> </small>
Colored Bananas flickr photo by Cleber Quadros shared under a Creative Commons (BY-NC) license

WSQ10 – Babylonian Method

Background

In this assignment you will write a function to calculate the square root of a number using the Babylonian method. You can search for that method, it will be easy to find.

What to Do

The function should receive a number and return floating point number. Obviously you should test your function, so create a main program that asks the user a value, calculates the square root and displays that.

What to Submit

As usual, create a blog post explaining what you did, where you found resources (books, videos, web pages, friends) to help you solve this. Remember to put the tag #WSQ10 on your post so our blog hub picks that up.

You should include your code as a link to GitHub.

And of course, leave any questions here as well as asking those questions on Twitter with the hashtag #TC1017 so we all see your question posted there.

Feature Image Credit

<a title="Babylonian Fresco" href="https://flickr.com/photos/brimley/4156702926">Babylonian Fresco</a> flickr photo by <a href="https://flickr.com/people/brimley">Brimley</a> shared under a <a href="https://creativecommons.org/licenses/by-nc/2.0/">Creative Commons (BY-NC) license</a> </small>
Babylonian Fresco flickr photo by Brimley shared under a Creative Commons (BY-NC) license

WSQ09 – Multipart Data and Files

Your Assignment

So for this assignment I would like to see you create a function that receives as parameter the name of a file (this would be a string value like data.txt) and your function counts the number of lines and the number of characters in the file which it returns as a single value (but with two values). You will want to look at how to create/define and return a struct value from a function and how to open and read text files line by line

What To Submit

As always a blog post, tag with #WSQ09 and perhaps put your code up on GitHub. Ask for help or input via Twitter (remember to use our course hashtag #TC1017).

Feature Image Credit

<a title="Files" href="https://flickr.com/photos/takashi/18862634">Files</a> flickr photo by <a href="https://flickr.com/people/takashi">T a k</a> shared under a <a href="https://creativecommons.org/licenses/by-nc/2.0/">Creative Commons (BY-NC) license</a> </small>
Files flickr photo by T a k shared under a Creative Commons (BY-NC) license

WSQ08 – Yo Soy 196

Background

Lychrel numbers are natural numbers that do not form a palindrome after successive additions to their inverse. See details on Wikipedia: http://en.wikipedia.org/wiki/Lychrel_number

What to Do

Your job is to create a program that asks the user for two pieces of data:

  • The lower bound of the sequence
  • The upper bound of the sequence
Then you check the values from the lower bound (inclusive) to the upper bound (inclusive) and make a report of them. During the analysis of each number, if a Lychrel number is found it should be reported immediately with something like “Found a Lychrel number: 196”

Details

The report must show:
  • The range of numbers analysed (lower to upper bound)
  • The number of natural palindromes (no addition to inverse needed)
  • The number of non-Lycherels encountered (become palindromes)
  • The number of Lycherel number candidates (that did not converge to palindrome)

Since you will not be able to prove that a number is Lycherel (since you cannot computer forever to check), our definition for a Lycherel candidate will be if a number does not converge after 30 iterations of applying the addition to the inverse.

To get this working well, you will need support for Big Integers. You can base your solution off my codebase on GitHub. Unzip all of the files in a directory and use the command “make” to compile. Run the executable.

How to use BigInteger and make

Video Demo

What to Submit

As usual, create a blog post explaining what you did, where you found resources (books, videos, web pages, friends) to help you solve this. Remember to put the tag #WSQ08  on your post so our blog hub picks that up.

You should include your code as a link to GitHub. You really should start using your GitHub repository now. If you need help on that, just ask Ken or your classmates.

And of course, leave any questions here as well as asking those questions on Twitter with the hashtag #TC1017 so we all see your question posted there.

Feature Image Credit

<a title="The Magic Numbers" href="https://flickr.com/photos/kenandpauline/5490820">The Magic Numbers</a> flickr photo by <a href="https://flickr.com/people/kenandpauline">K & P</a> shared under a <a href="https://creativecommons.org/licenses/by-nc-nd/2.0/">Creative Commons (BY-NC-ND) license</a> </small>
The Magic Numbers flickr photo by K & P shared under a Creative Commons (BY-NC-ND) license

WSQ07 – Lists

What to Do

creative commons licensed (BY-NC-SA) flickr photo by Mark Morgan Trinidad A: http://flickr.com/photos/mmorgan8186/5946796450
creative commons licensed (BY-NC-SA) flickr photo by Mark Morgan Trinidad A: http://flickr.com/photos/mmorgan8186/5946796450

 

 

 

Create a program that asks the user for 10 numbers  (floating point). Store those numbers in a list. Show to the user the total, average and standard deviation of those numbers.

Details

For the C++ group you can do this with arrays or Vectors, but you will need to know eventually how to do both.

Once you have this working, change it so that users keep giving you values until they signal “no more values”. How would you implement this and in particular for the C++ group, how to you deal with an unknown size to your array during compilation?

What to Submit

As usual, create a blog post explaining what you did, where you found resources (books, videos, web pages, friends) to help you solve this. Remember to put the tag #WSQ07 on your post so our blog hub picks that up.

You should include your code as a link to GitHub. You really should start using your GitHub repository now. If you need help on that, just ask Ken or your classmates.

If you have not seen my video yet about the GUI tutorial for GitHub, go check that out: http://youtu.be/YQmlksGFZWY

And of course, leave any questions here as well as asking those questions on Twitter with the hashtag #TC1017 so we all see your question posted there.

WSQ06 – Factorial Calculator

What to Do

creative commons licensed (BY-SA) flickr photo by ▓▒░ TORLEY ░▒▓: http://flickr.com/photos/torley/3505324528
creative commons licensed (BY-SA) flickr photo by ▓▒░ TORLEY ░▒▓: http://flickr.com/photos/torley/3505324528

 

 

 

 

 

 

Create a program that asks the user for a non-negative integer (let’s call that number n) and display for them the value of n! (n factorial).

After showing them the answer, ask them if they would like to try another number (with a simple y/n response) and either ask again (for y) or quit the program and wish them a nice day (if they answered n).

Details

There are two basic approaches: a loop with an accumulator of the multiplication and a recursive solution. Choose one and implement that. Once that is done, try the other way.

If you used a while loop for the solution with a loop, try structuring this with a for loop (or vice-versa).

What to Submit

As usual, create a blog post explaining what you did, where you found resources (books, videos, web pages, friends) to help you solve this. Remember to put the tag #WSQ06 on your post so our blog hub picks that up.

You should include your code as a link to GitHub. You really should start using your GitHub repository now. If you need help on that, just ask Ken or your classmates.

If you have not seen my video yet about the GUI tutorial for GitHub, go check that out: http://youtu.be/YQmlksGFZWY

And of course, leave any questions here as well as asking those questions on Twitter with the hashtag #TC1017 so we all see your question posted there.

WSQ05 – On To Functions

What to Do

creative commons licensed (BY) flickr photo by kevin dooley: http://flickr.com/photos/pagedooley/8435953365
creative commons licensed (BY) flickr photo by kevin dooley: http://flickr.com/photos/pagedooley/8435953365

 

 

 

 

 

 

You will go back and do WSQ01 – Fun with Numbers again.

But this time, write a function for each calculation. Each function should define two parameters (in this example of type int) and return the correct value as an integer as well.

You main program needs to ask the user for the input and then call each function to calculate the answer for each of the parts.

What to Submit

As usual, create a blog post explaining what you did, where you found resources (books, videos, web pages, friends) to help you solve this. Remember to put the tag #WSQ05 on your post so our blog hub picks that up.

You should include your code either inline in the blog post (best option) and/or a link to your actual code on Dropbox/Google Drive/GitHub.

If you have not seen my video yet about the GUI tutorial for GitHub, go check that out: http://youtu.be/YQmlksGFZWY

And of course, leave any questions here as well as asking those questions on Twitter with the hashtag #TC1017 so we all see your question posted there.

WSQ04 – Sum of Numbers (Week 05)

What to Do

https://www.flickr.com/photos/wisamallami/2478134485/

https://www.flickr.com/photos/wisamallami/2478134485/

Write a program that asks for a range of integers and then prints the sum of the numbers in that range (inclusive).

You can use a formula to calculate this of course but what we want you to do here is practice using a loop to do repetitive work.

For example, the sum from 6 to 10 would be 0 + 6 + 7 + 8 + 9 + 10.

Notice our sum starts with zero (why?) and then we add each number in the range provided by the user. Just for fun, what is the mathematical formula to do this calculation?

Example Run

We will calculate the sum of integers in the range you provide.
Please give us the lower bound:  1
Please give us the upper bound: 10
The sum from 1 to 10 (inclusive) is: 55

Thoughts

How would you change your program to handle the user giving you the upper and lower bound in the wrong order? Or perhaps some other “user input error”?

What to Submit

As usual, create a blog post explaining what you did, where you found resources (books, videos, web pages, friends) to help you solve this. Remember to put the tag #WSQ04 on your post so our blog hub picks that up.

You should include your code either inline in the blog post (best option) and/or a link to your actual code on Dropbox/Google Drive/GitHub.

You may want to check how to get started on GitHub now, here is a good article to start with: http://readwrite.com/2013/09/30/understanding-github-a-journey-for-beginners-part-1

And of course, leave any questions here as well as asking those questions on Twitter with the hashtag #TC1017 and #WSQ04 so we all see your question posted there.