An “enjoyable” introduction to Programming Dr. Jeyakesavan Veerasamy Senior Lecturer University of Texas at Dallas

Slides:



Advertisements
Similar presentations
An enjoyable introduction to Programming Dr. Jeyakesavan Veerasamy CS faculty, University of Texas at Dallas Website:
Advertisements

Microsoft® Small Basic
1 ICS102: Introduction To Computing King Fahd University of Petroleum & Minerals College of Computer Science & Engineering Information & Computer Science.
Welcome to C++ Programming Workshop at The University of Texas at Dallas Presented by John Cole July 8-12, 2013.
COMPUTER PROGRAMMING I Understand Problem Solving Tools to Design Programming Solutions.
Lets Play Catch! Keeping Score in Alice By Francine Wolfe Duke University Professor Susan Rodger May 2010.
Programming Types of Testing.
Repetition Structures
CS320n –Visual Programming Indefinite Loops (Slides 7-2) Thanks to Wanda Dann, Steve Cooper, and Susan Rodger for slide ideas.
Chapter 2: Algorithm Discovery and Design
Introduction to Alice Basics : What is Alice? Object Oriented Definitions What Does it Look Like? Where Can I Use it?
Main task -write me a program
Chapter 2: Algorithm Discovery and Design
Chapter 3 Planning Your Solution
Alice: A Free 3D Animation World for Teaching Programming Barbara Ericson Georgia Institute of Technology Oct 2005.
Gentle Introduction to Programming in Java Dr. Jey Veerasamy 1.
An “enjoyable” introduction to Programming Dr. Jeyakesavan Veerasamy The University of Texas at Dallas, USA Alice.
Lecture 15 Practice & exploration Subfunctions: Functions within functions “Guessing Game”: A hands-on exercise in evolutionary design © 2007 Daniel Valentine.
DCT 1123 PROBLEM SOLVING & ALGORITHMS INTRODUCTION TO PROGRAMMING.
Line up By Melissa Dalis Professor Susan Rodger Duke University June 2011.
JS Arrays, Functions, Events Week 5 INFM 603. Agenda Arrays Functions Event-Driven Programming.
REPETITION STRUCTURES. Topics Introduction to Repetition Structures The while Loop: a Condition- Controlled Loop The for Loop: a Count-Controlled Loop.
Abstraction IS 101Y/CMSC 101 Computational Thinking and Design Tuesday, September 17, 2013 Carolyn Seaman University of Maryland, Baltimore County.
by Chris Brown under Prof. Susan Rodger Duke University June 2012
Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and Elizabeth Drake Chapter 2: Developing a Program.
Chapter 5: Control Structures II (Repetition)
CHAPTER 5: CONTROL STRUCTURES II INSTRUCTOR: MOHAMMAD MOJADDAM.
EGR 2261 Unit 5 Control Structures II: Repetition  Read Malik, Chapter 5.  Homework #5 and Lab #5 due next week.  Quiz next week.
Study Guide For Test Chapter 5, 6,& 7 Test is Friday, May 15th.
Invitation to Computer Science, Java Version, Second Edition.
Abstraction IS 101Y/CMSC 101 Computational Thinking and Design Tuesday, September 17, 2013 Marie desJardins University of Maryland, Baltimore County.
Learning the skills for programming Advanced Visual Programming.
CS329e – Elements of Visual Programming Implementing Programs Mike Scott (Slides 2-2)
By the end of this session you should be able to...
Game Programming in Java Dr. Jeyakesavan Veerasamy CS faculty, The University of Texas at Dallas Website:
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 5: Software Design & Testing; Revision Session.
© 2011 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Stewart Venit ~ Elizabeth Drake Developing a Program.
Overview of this morning What … is computing? Why … is computing an important skill to learn? What … will my child be learning in computing lessons?
Conditions. Objectives  Understanding what altering the flow of control does on programs and being able to apply thee to design code  Look at why indentation.
Problem Solving Techniques. Compiler n Is a computer program whose purpose is to take a description of a desired program coded in a programming language.
© Jalal Kawash Programming Peeking into Computer Science 1.
1 09/20/04CS150 Introduction to Computer Science 1 Let ’ s all Repeat Together.
Mathematical Expressions, Conditional Statements, Control Structures
Software Development. Software Development Loop Design  Programmers need a solid foundation before they start coding anything  Understand the task.
Tutorial for Arrays and Lists. Description This presentation will cover the basics of using Arrays and Lists in an Alice world It uses a set of chickens.
An “enjoyable” introduction to Programming Dr. Jeyakesavan Veerasamy CS faculty, The University of Texas at Dallas Website:
Data Structure Introduction Dr. Bernard Chen Ph.D. University of Central Arkansas Fall 2010.
CS320n –Visual Programming Definite / Counted Loops (Slides 7-1) Thanks to Wanda Dann, Steve Cooper, and Susan Rodger for slide ideas.
5 Event Handling Interactive Programming Suggested Reading Interaction: Events and Event Handling, Supplemental Text for CPSC 203 Distributed this term.
Alice: A Free 3D Animation World for Teaching Programming.
Intro to Loops 1.General Knowledge 2.Two Types of Loops 3.The WHILE loop 1.
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Tevfik Bultan Lecture 4: Introduction to C: Control Flow.
Algorithms and Pseudocode
Chapter 2: Algorithm Discovery and Design Invitation to Computer Science.
CS320n –Visual Programming Execution Control with If / Else and Boolean Functions (Slides 6-2-1) Thanks to Wanda Dann, Steve Cooper, and Susan Rodger for.
Progression in KS3/4 Algorithms MONDAY 30 TH NOVEMBER SUE SENTANCE.
1 Structured Programming Arab Academy for Science and Technology CC112 Dr. Sherif Mohamed Tawfik The Course.
Algorithms and Flowcharts
1 Quiz Show Programming Terms. 2 Alice - 3D Virtual Programming Vocabulary Quiz Board Chapter 1 Chapter 2a Chapter 2b Chapter 3 Chapter 4 $100 $200 $300.
Scratch Programming Cards
An “enjoyable” introduction to Programming
Lesson 5-2 AP Computer Science Principles
An introduction to programming Created by Dr. Randy Pausch
Introduction to Programmng in Python
Learning Java with Alice 3.0 Game Design Kathy Bierscheid
PYTHON: BUILDING BLOCKS Sequencing & Selection
ICT Gaming Lesson 2.
Module 4 Loops and Repetition 9/19/2019 CSE 1321 Module 4.
Presentation transcript:

An “enjoyable” introduction to Programming Dr. Jeyakesavan Veerasamy Senior Lecturer University of Texas at Dallas

Programmable device?

What is programming? Set up parameters such that same device can be made to do several different things.

Why learn programming? Automation continues… Computer touches our lives more & more every day… More component based programming  always room for simple programs to do large tasks!

Learning to ride bicycle Difficulties for beginners: Difficulties for experienced folks:

Solution Training wheels Helmet Makes learning enjoyable and safe!

Learning to program: Difficulties for beginners 1.Syntax errors struggle for hours to fix syntax errors Loose confidence Frustrating experience Run away & never come back if possible! 2. Logic errors Not a serious issue.

Difficulties for experienced programmers Logic errors Continuous learning

Solution Visual Programming Tools to teach programming concepts without encountering syntax errors

Introduction to Alice Developed at Carnegie Mellon University and available freely for every one! Website: Alice 2.2 Software

Programming Concepts

A few examples Recipe to make your favorite food Assembly instructions for a toy Coming to college from home What is common about these activities?

Programming concepts: Sequence structure instruction 1; instruction 2; instruction 3; …

A few more examples Study at home or play cricket with friends? Eat Parotta or Poori? Go to Vijay’s movie or Karthik’s movie? Go to job or go for higher studies? What is the common thing here?

Selection structure IF condition is true THEN do this; ELSE do that; ENDIF

A few more examples Eat chips from a packet Go on a shopping spree with lot of cash! Take an exam that has several questions What is the common thing here?

Repetition structure WHILE (more items to process) process the next item; ENDWHILE FOR month = 1 to 12 do monthly processing ENDFOR

Object Oriented Programming (OOP) Models the real-world better

Purpose of Alice Enjoyable introduction to Programming Natural introduction to OOP Learning to program with training wheels Stepping stone to learn more serious languages (C/C++/Java)

Hands-on Introduction to Alice It is a good idea to save each program separately so that you can go back and review later.

Alice environment World Gallery Creating the initial scene – Adding objects – Working with objects

Program #1: Choose your favorite object from the gallery and make it an interesting setup. 10 minutes?

Our first program! Sequence structure do a few interesting actions!

Program #2: Make your object do a few funny actions! 10 minutes?

Program #3 Introduce multiple objects do a few interesting actions!

Program #3: Make your objects do a few funny actions! 15 minutes?

Program #4 Use DO TOGETHER structure Add realism & sophistication!

Program #4: Use DO TOGETHER to do multiple things at same time! 20 minutes?

Program #4a Add Vehicles/Seaplane from local gallery. Make it do loop the loop. Use DO TOGETHER structure – seaplane move forward – seaplane turn backward – seaplane’s propeller roll right Use “style = abruptly” to make the motion smooth

Program #4a: Use DO TOGETHER to make the plane do loop the loop! 20 minutes?

Program #5 Introduce repetition – counted loop do a few interesting actions!

Program #5: Make your objects do a few funny actions multiple times! 10 minutes?

Program #6 Use condition to stop the loop. do a few interesting actions!

Program #6: Make your objects do a few funny actions multiple times, but stop when a particular condition is met. 15 minutes?

Program #7 How to do realistic walking? Leg & body movements Better to do with human objects Create new methods

Program #7: Practice human walking/running animation 15 minutes?

Program #8 Walking back and forth between 2 points? Discuss the ideas before coding! Use methods?

Program #8: Practice human walking/running back & forth. 15 minutes?

Program #9 Alternate implementation of Program #8 using IF statement Variables Decision statement

Program #9: Practice variables and decision structure 15 minutes?

Logical thinking You have been introduced to several building blocks – a few more on the way too. Now, it is all about putting/using them together in various combinations. I encourage you to think in high level, note down a few ideas (design), then proceed to implementation. Direct coding is NOT recommended.

Program #10: Lists/Arrays Arrays cannot expand during run-time, but lists can. Alice supports more functionality with lists too. In simple words, lists are more powerful. Make a list of your favorite objects (multiple copies of an object is ok too!) Make them do something one at a time. Make them do something in random order Make them do something in sync. You are not limited to these - use your imagination!

Program #10: Play with lists & practice each one. 15 minutes?

Event-driven programming Deletion of individual methods or objects possible - just drag it to Trashcan! We will cover event driven programming today. Analogy: handling interruptions when you are watching a movie or studying hard for an exam. Related note: Time management is very crucial in modern life.

Program #11: Events So far, we did all the work under “my first method”. But when it comes to games or complex apps, user may press various buttons/items & we need to respond to each event.

Program #11: We will start with a coach and a ball. Coach keeps doing some exercise. We will use key based events to move a ball to top of his head. Then, coach should stop exercising and do something funny. 15 minutes?

Program #12: Frog’s jumping game! Swimming pool – moving lilypads – make the frog to jump on lilypads carefully and reach other side to win! Make the lilypads to move independently back and forth first. Then, work on the game. If the frog jumps and touches the water, it will sink! I guess this frog does not know to swim  Plan and write the pseudocode first, before coding!

Program #12: Frog jumping game. Discuss/share ideas with your neighbour and help each other to progress … Move frog 0.7 meters forward when up-arrow is pressed. For moving lilypads, use distance (pool width – cricle width) with bit random speed. Use vehicle property to stick to lilypad.

High level idea/pseudocode #1 move the frog by 0.7 meters. IF index is beyond lilypads declare win! ELSE IF frog is close to circles[index] frog is safe set vehicle for frog to corresponding circle ELSE frog dies! – make frog disappear display a message ENDIF increment index

High level idea/pseudocode #2 move the frog by 0.7 meters. IF frog is close to “finish” object, declare win! ELSE IF frog is close to any of the moving circles frog is safe set vehicle for frog to corresponding circle ELSE frog dies! – make frog disappear display a message ENDIF

Transition to C/C++/Java Most of you have become “mature” Alice programmers – you can see the limitations of Alice now. Now that your fundamentals are bit strengthened, this is a great time to get started with C/C++/Java! Time management is crucial – I encourage you to spend a few hours to solve programming problems periodically to strengthen your skills.

Transition to C/C++/Java: Math Practice program You can program the following problem in Alice or C/C++/Java or both. Display 2 random numbers (limit the range for each number to 1-100) and ask the user to multiply manually & input the result. Verify whether the user input is correct. Repeat it for 10 times, keep track of the score and display it in the end like this: Your score: 8 correct, 2 incorrect.

Transition to C/C++/Java: Guessing Game First, guess a number between 1 and 100. Then, your program should ask you a series of questions and determine your guess based on your answers. Question format: How about NN ( )? Develop the high level idea first.

Pseudocode initialize low = 1, high = 100 WHILE low < high mid = (low + high) / 2 ask the user how about mid? IF user response is < high = mid-1 ELSE IF user resposne is > low = mid+1 ELSE IF user response is = print great! break; IF low == great print “Your guess is” low ENDIF

Sample run #1 (user input in RED) Guess a number between 1 and 100 (both inclusive) and get ready to answer a few questions. How about 50 ( )? < How about 25 ( )? < How about 12 ( )? > How about 18 ( )? > How about 21 ( )? < How about 19 ( )? > Your guess is 20.

Sample run #2 (user input in RED) Guess a number between 1 and 100 (both inclusive) and get ready to answer a few questions. How about 50 ( )? > How about 75 ( )? < How about 62 ( )? > How about 68 ( )? = Your guess is 68.

Reverse Guessing Game Play the reverse game. Computer should guess a number between 1 and 100. Now, you should ask questions & determine that number. C/C++: use srand() and rand() to generate random numbers Discuss the algorithm first before coding!

Pseudocode guess = Generate a random number 1 … 100 Ask for user input WHILE user input != guess IF guess < user input output “<“ ELSE output “>” Ask for user input Output “You guessed it right. Good game!”

Sample run I have guessed a number. You can ask questions now. 50 < 25 < 12 > 18 > 21 < 19 > 20 = Good job!

References Alice website: Textbook: Learning to Program with Alice by Wanda Dann, Steve Cooper and Randy Pausch ISBN: Ebook: