This document provides an introduction to coding concepts. It discusses storing values in variables and data types like strings and integers. Key coding concepts covered include comments, running code, comparisons, arrays, and if/else statements. The document outlines what future sessions will cover, including loops, classes, methods, connecting to databases, and using other people's code.
Teaching Notes (extremely technical) detailing my Raspberry Pi program. This is for the third set of classes, where we taught the Python coding language along with logic structure. This is the first class, showing the basics of Python.
I am Tim D. I am a Python Homework Expert at pythonhomeworkhelp.com. I hold a Master's in Python from, West Virginia University, USA. I have been helping students with their homework for the past 10 years. I solve homework related to Python.
Visit pythonhomeworkhelp.com or email support@pythonhomeworkhelp.com.
You can also call on +1 678 648 4277 for any assistance with Python Homework.
Teaching Notes (extremely technical) detailing my Raspberry Pi program. This is for the third set of classes, where we taught the Python coding language along with logic structure. This is the first class, showing the basics of Python.
I am Tim D. I am a Python Homework Expert at pythonhomeworkhelp.com. I hold a Master's in Python from, West Virginia University, USA. I have been helping students with their homework for the past 10 years. I solve homework related to Python.
Visit pythonhomeworkhelp.com or email support@pythonhomeworkhelp.com.
You can also call on +1 678 648 4277 for any assistance with Python Homework.
Python 101: Python for Absolute Beginners (PyTexas 2014)Paige Bailey
If you're absolutely new to Python, and to programming in general, this is the place to start!
Here's the breakdown: by the end of this workshop, you'll have Python downloaded onto your personal machine; have a general idea of what Python can help you do; be pointed in the direction of some excellent practice materials; and have a basic understanding of the syntax of the language.
Please don't forget to bring your laptop!
Audience: "Python 101" is geared toward individuals who are new to programming. If you've had some programming experience (shell scripting, MATLAB, Ruby, etc.), then you'll probably want to check out the more intermediate workshop, "Python 101++".
It's a talk about how to write understandable code from understanding human brain at Taipei.py [1] and PyCon HK 2015 [2].
[1]: http://www.meetup.com/Taipei-py/events/222174472/
[2]: http://2015.pycon.hk/
CIS 1403 Lab 2- Data Types and VariablesHamad Odhabi
This lab aims to develop the student knowledge and skills data types, required memory storage for each data type, selection of appropriate data types, naming variables, This lab aims to develop the student knowledge, and skills in identifying the appropriate data-types for variables, calculate the required memory storage for each data type, naming variables, casting of data types, and mathematic operations, the casting of data types, and arithmetic operations.
Python 101: Python for Absolute Beginners (PyTexas 2014)Paige Bailey
If you're absolutely new to Python, and to programming in general, this is the place to start!
Here's the breakdown: by the end of this workshop, you'll have Python downloaded onto your personal machine; have a general idea of what Python can help you do; be pointed in the direction of some excellent practice materials; and have a basic understanding of the syntax of the language.
Please don't forget to bring your laptop!
Audience: "Python 101" is geared toward individuals who are new to programming. If you've had some programming experience (shell scripting, MATLAB, Ruby, etc.), then you'll probably want to check out the more intermediate workshop, "Python 101++".
It's a talk about how to write understandable code from understanding human brain at Taipei.py [1] and PyCon HK 2015 [2].
[1]: http://www.meetup.com/Taipei-py/events/222174472/
[2]: http://2015.pycon.hk/
CIS 1403 Lab 2- Data Types and VariablesHamad Odhabi
This lab aims to develop the student knowledge and skills data types, required memory storage for each data type, selection of appropriate data types, naming variables, This lab aims to develop the student knowledge, and skills in identifying the appropriate data-types for variables, calculate the required memory storage for each data type, naming variables, casting of data types, and mathematic operations, the casting of data types, and arithmetic operations.
CMIS 102 Hands-On Lab
// Week 4
Overview:
This hands-on lab allows you to follow and experiment with the critical steps of developing a program including the program description, analysis, test plan, design (using both flow chart and pseudocode visualization), and implementation with C code. The example provided uses sequential, selection and repetition statements.
Program Description:
This program will calculate the sum of 10 integers. The program will ask the user to 10 integers. If the sum of the numbers is greater than 1000, a message is printed stating the sum is over 1000. The design step will include both pseudocode and flow chart visualization.
Analysis:
I will use sequential, selection and repetition programming statements.
I will define three integer numbers: count, value, sum. Count will store how many times values are entered to make sure we don’t exceed 10 values. Value will store the input integer and sum will store the running sum.
The sum will be calculated by this formula:
sum = sum + value
For example, if the first value entered was 4 and second was 10:
sum = sum + value = 0 + 4
sum = 4 + 10 = 14
Values and sum can be input and calculated within a repetition loop:
while count <10
Input value
sum = sum + value
End while
The additional selection statement will be of this form:
If sum > 1000 then
print "Sum is over 1000"
End If
Test Plan:
To verify this program is working properly the input values could be used for testing:
Test Case
Input
Expected Output
1
value=1
value=1
value=1
value=0
value=1
value=2
value=0
value=1
value=3
value=2
Sum = 12
2
value=100
value=100
value=100
value=100
value=100
value=200
value=200
value=200
value=200
value=200
Sum = 1200
Sum is over 1000.
3
value=-100
value=-100
value=-200
value=0
value=200
value=100
value=0
value=200
value=-300
value=-200
Sum = -400
Pseudocode:
// This program will calculate the sum of 10 integers.
// Declare variables
Declare count, value, sum as Integer
//Initialize Counter, Sum to 0
Set count=0
Set sum = 0
// Loop through 10 integers
While count < 10
Print “Enter an Integer”
Input value
sum = sum + value
count=count+1
End While
// Print results and messages
Print “Sum is “ + sum
If (sum > 1000)
Printf “Sum is over 1000”
End if
Flow Chart:
C Code
The following is the C Code that will compile in execute in the online compilers.
// C code
// This program will calculate the sum of 10 integers.
// Developer: Faculty CMIS102
// Date: Jan 31, 2014
#include <stdio.h>
int main ()
{
/* variable definition: */
int count, value, sum;
/* Initialize count and sum */
count = 0;
sum = 0;
// Loop through to input values
while (count < 10)
{
printf("Enter an Integer\n");
scanf("%d", &value);
sum = sum + value;
count = count + 1;
}
printf("Sum is %d\n " , sum );
if (sum >1000)
printf("Sum is over 1000\n");
return 0;
}
Setting up the code and the input parameters in ideone.com:
Note the input integer.
2. We Tried To Get Jeremy To Teach
But...
3:49:17 PM Ashley Thompson: I will work on Jeremy.
3:49:30 PM Ashley Thompson: He told me to contact his
agent… which isn't a "no".
3. ● You will see coding
● You will learn basic concepts
● You will know where to go to practice
● You will know where to go with questions
What Today's Session Will Do
4. ● Teach you ever more advanced concepts
● Teach you how to code on your local box
● Teach you how to leverage existing code
● Build stuff that is day to day useful
What Future Sessions Will Do
5. There are too many concepts to pack into an
hour.
We're going to go in smaller chunks.
We are "eating our veggies" today by learning a
lot of concepts which will relate later.
No SQL Today
6. What Is Coding?
Playing with numbers and words until they are
useful, then saving them and reusing them.
7. Computers vs. Humans
Computers are like this 10101101010101.
Humans are like this "hi! k. thx, bye"
This is "hi! k. thx, bye" in computer:
01101000011010010010000100100000011010
11001011100010000001110100011010000111
10000010110000100000011000100111100101
100101
8. Code Like A Human
I do not want to write a bunch of 1s and 0s.
I need a coding language to take my English
and turn it into 1s and 0s for me.
Many good languages do this.
I like Ruby.
9. Where Do I Go To...Ruby?
To punch stuff in and see what Ruby does:
● http://tryruby.org/
To go through a structured, type it in course:
● http://www.codeacademy.com/tracks/ruby
10. Where Do I Go To...Ruby?
To ask questions to other coders:
http://stackoverflow.com/questions/tagged/ruby
11. Today's Coding Concepts
● Words and Numbers
● Storage
● Comments
● Running Code
● Comparisons
● Arrays
● Commands On Variables
● If/Else Statement
12. Words
In code, you store words in Strings.
Examples:
● "I am a string because I am words"
● "I am also a string"
● "jello"
Quote signs tell the computer that its a String.
13. Numbers
In code, you store numbers in Integers.
Examples:
● 5
● 555
● 102125
No quote strings needed.
14. You'll need to do three things to store stuff:
● To make up a name
● Type an equals sign
● Type a word or number
Example:
save_me = "this will be stored to save_me"
Storing Values
15. pudding = "word or number"
The made up name pudding is commonly
called a variable.
johnny = "hi hi"
carolyn = "bye bye"
johnny and carolyn are variables.
Storing Values
16. Lets store "my words" to the my_value variable:
my_value = "my words"
Display that variable with the puts command:
puts my_value
=> "my words"
Storing Values
17. Examples of how to store Strings:
words = "my words"
oscar = "grouch"
johnny = "occasionally grouchy"
Storing Values
18. Examples of how to store Integers:
total = 5 + 4
another = 10 - 3
last = 42 * 125
Storing Values
19. Another Example:
pudding = "tasty goodness"
puts pudding
=> "tasty goodness"
This is because we stored "tasty goodness" to
pudding, then said "print the value of pudding"
Storing Values
20. Storing Values
You can use variables just as if they were the
original value they store.
Example:
one = 1
two = 2
three = one + two
puts three
=> 3
21. Storing Values
You can overwrite variables with new data
var = "this won't last"
puts var
=> "this won't last"
var = "overwrite the current data"
puts var
=> "overwrite the current data"
22. Storing Values
You can store variables to other variables
Number Example:
one = 1
also_one = one
puts also_one
=> 1
23. Comments tells the computer to skip the line.
The symbol for a comment is the # sign.
Here are what comments look like:
#var1 = "test"
#my comment line will be skipped
#var1 = "test2" a third skipped line
Comments
24. Comments are used by coders to add context,
warning and overviews of code
#This will store "hi" to myvar
myvar = "hi"
#This will store 2 + 2 to the variable four
four = 2 + 2
Comments
25. To run code:
1. Go to the command line
2. Type in Ruby code
3. Get a response from Ruby
Running Code, The Command Line
26. Where do you find command lines?
1. Inside tutorials like codeacademy/tryruby
2. On your computer, if ruby is installed (irb)
3. On other computers where ruby is installed,
like if IT configures one and gives you creds
Running Code, The Command Line
27. Lets move to the command line and run
examples we've worked on so far.
1. Johnny's command line
2. The code academy tutorial
Running Code, The Command Line
28. If Ruby is installed on your computer:
1. Create a file.
2. Make it end in .rb (instead of .doc, .txt, etc)
3. Navigate to the file's directory via command
line
4. $>ruby my_file.rb
Running Code, From A File
29. If you have downloaded a Ruby focused text
editor, you can also load and run the file right
from the GUI.
Lets pause for examples.
Running Code, From A File
30. The == sign tells us if two values are equal:
1 == 1
=> true
1 == 2
=> false
Comparisons
31. one = 1
two = 2
one == 1
=> true
one == two
=> false
Comparisons
33. Arrays
Arrays let you store a group of the same data to
one variable.
Some examples of groups:
people = ['johnny', 'robert', 'nelson', 'jayson']
animals = ['sloth', 'toad', 'zebra']
presidents = ['clinton', 'bush', 'obama']
34. Arrays
To get all that data back out
$> people
=> ["johnny", "robert", "nelson", "jayson"]
$> puts people
johnny
robert
nelson
jayson
35. Arrays
To get only one element out, you need to learn
a trick...
Arrays are zero indexed.
Meaning you count and reference the elements
from 0.
38. Commands On Variables
First, lets just look at it:
people
=> ['johnny', 'robert', 'nelson', 'jayson']
people.count
=> 4
39. Commands On Variables
You can call commands on variables.
Structure:
<variable>.<command>
Example:
people.count
=> 4
40. Commands On Variables
Here's another one:
people
=> ["johnny", "robert", "nelson", "jayson"]
people.reverse
=> ["jayson", "nelson", "robert", "johnny"]
41. Commands On Variables
If you want to see all the commands you are
allowed to call on a given variable, use the
methods command
people.methods
=> [:inspect, :to_s, :to_a, :to_ary, :frozen?,:==, :
eql?, :hash, :[], :[]=, :at, :fetch, :first, :last, :
concat, :<<, :push, :pop, :shift, :unshift, :insert, :
each, :each_index, :reverse_each, :length, :
size, :empty?, :find_index, :index, :count]
42. More Helpful Array Commands
Add a new person to people:
people.push('jenny')
=> ["johnny", "robert", "nelson", "jayson",
"jenny"]
43. More Helpful Array Commands
Remove the last person from people:
people.pop
=> "jenny"
people
=> ["johnny", "robert", "nelson", "jayson"]
44. If/Else Statement
A variable's value can be used as a decision
point that determines which code to run next.
You do this using an if / else statement.
45. If/Else Statement, Structure
If / Else Structure:
if variable == <value>
#run this code if true
else
#run this code if false
end
46. If/Else Statement, Example 1
one = 1
if one == one
puts "true, one equals one"
else
puts "false, one does not equal one"
end
=> "true, one equals one"
47. If/Else Statement, Example 2
one = 1
if one == 2
puts "true, one equals one"
else
puts "false, one does not equal one"
end
=> "false, one does not equal one"
49. The Big Picture
A web page does this:
1. Queries a database and stores data to
arrays
2. Loops through the arrays
3. Manipulates elements of the arrays
4. Displays results to the user
50. The Big Picture
You know:
1. How to create and store variables
2. How to manipulate variables with commands
3. About arrays
4. How to decide which code to run via IF/Else
51. The Big Picture
You do not know:
1. How to loop through arrays
2. How to wrap code in reusable methods
3. How to wrap methods in reusable classes
4. How to use other peoples code
52. The Big Picture
Once you fill those holes in, you have the core
concept of how to build any web page.
You can also look at a web page and say "I
know how they did that" in a conceptual way.
53. The Big Picture
Code is slowly automating everything.
Code is the new universal language.
Nearly every other skill will eventually be code
involved or code dependant.
Be in the "can code" part of the work force.
54. Next Time
● Loops
● Arrays + Loops
● Classes and Methods
● Connecting To Databases
● Looping Through Database Query Results
● Using Other People's Code In Yours