H446 Computer Science.

Slides:



Advertisements
Similar presentations
Making Choices in C if/else statement logical operators break and continue statements switch statement the conditional operator.
Advertisements

1 9/29/06CS150 Introduction to Computer Science 1 Loops Section Page 255.
1 9/29/06CS150 Introduction to Computer Science 1 Loops Section Page 255.
1 9/28/07CS150 Introduction to Computer Science 1 Loops section 5.2, 5.4, 5.7.
1 9/1/06CS150 Introduction to Computer Science 1 What Data Do We Have? CS 150 Introduction to Computer Science I.
1 September 6, 2005CS150 Introduction to Computer Science I What Actions Do We Have Part 1 CS150 Introduction to Computer Science I.
Arrays Chapter 8 page /24/07CS150 Introduction to Computer Science 1 Arrays (8.1)  One variable that can store a group of values of the same.
Formula Practice Find the area for the figure below. 12 m 6 m Answer: #1.
Chapter 1 Pseudocode & Flowcharts
Microsoft® Small Basic
PYTHON: PART 2 Catherine and Annie. VARIABLES  That last program was a little simple. You probably want something a little more challenging.  Let’s.
Data & Data Types & Simple Math Operation 1 Data and Data Type Standard I/O Simple Math operation.
More While Loop Examples CS303E: Elements of Computers and Programming.
How to start Visual Studio 2008 or 2010 (command-line program)
Writing Program Code in BASIC Write a program to prompt for and accept values into TWO variables, numx and numy. The program should square the value stored.
Writing JavaScript Functions. Goals By the end of this unit, you should understand … How to breakdown applications into individual, re-usable modules.
CS161 Topic #16 1 Today in CS161 Lecture #16 Prepare for the Final Reviewing all Topics this term Variables If Statements Loops (do while, while, for)
ITI 1120 Lab #5 Contributors: S. Boyd, R. Plesa, A. Felty, D. Inkpen, A. Williams, D. Amyot.
CSC 1010 Programming for All Lecture 3 Useful Python Elements for Designing Programs Some material based on material from Marty Stepp, Instructor, University.
INPUT & VARIABLES.
Debugging, Escape Command, More Math. It’s your birthday!  Write a program that asks the user for their name and their age.  Figure out what their birth.
CS 101 – Oct. 15 Common elements in solutions –Types of variables –Traversing values in a list –Assigning vs. checking if equal –Printing things on the.
Lecture 5: Expressions and Interactivity Professor: Dr. Miguel Alonso Jr. Fall 2008 CGS2423/COP1220.
Introduction to Programming Python Lab 3: Arithmetic 22 January PythonLab3 lecture slides.ppt Ping Brennan
Exercise 1 #include int main() { printf(“Hello C Programming!\n”); return 0; } 1.Run your Visual Studio 2008 or Create a new “project” and add.
Introduction to Programming Python Lab 5: Strings and Output 05 February PythonLab5 lecture slides.ppt Ping Brennan
GCSE Computing: Programming GCSE Programming Remembering Python.
Computer Programming 12 Mr. Jean March 5 th, 2014.
Introduction to Programming Python Lab 7: if Statement 19 February PythonLab7 lecture slides.ppt Ping Brennan
Computer Programming Arrays 1. Question #1 2 Question Choose the correct answer..
Introduction to Programming Python Lab 8: Loops 26 February PythonLab8 lecture slides.ppt Ping Brennan
CS 240 Computer Programming 1
Lesson 3-7 Pages Using Formulas. What you will learn! 1. How to solve problems by using formulas. 2. How to solve problems involving the perimeters.
Input, Output and Variables GCSE Computer Science – Python.
Few More Math Operators
7 - Programming 7J, K, L, M, N, O – Handling Data.
GCSE COMPUTER SCIENCE Practical Programming using Python
Numbers and arithmetic
CMSC201 Computer Science I for Majors Lecture 03 – Operators
Some Assignments  Write a program which prints the following information about at least 5 persons: NAME MAIL-ID EMPLOYEE-CODE PHONE Eg. Umesh
Numbers and Arithmetic
What Actions Do We Have Part 1
Chapter 1 Introduction to Java
Introduction to Algorithms
Data Types and Conversions, Input from the Keyboard
Making Choices with if Statements
Computing Fundamentals
Bell work 9/18 to 9/22.
Introduction to Programming
Variables, Expressions, and IO
Basic operations in Matlab
Starter Questions Convert the following to minutes :-
To write a Python program, you first need to open Pyscripter
CMSC201 Computer Science I for Majors Lecture 03 – Operators
Computational Thinking
Computational Thinking
Chapter 4 LOOPS © Bobby Hoggard, Department of Computer Science, East Carolina University / These slides may not be used or duplicated without permission.
IDENTIFIERS CSC 111.
Chapter 2 Elementary Programming
Objective- To use variables in formulas to describe situations.
Introduction to Programming
Programming Control Structures
What Actions Do We Have Part 1
Introduction to Computer Science
Introduction to Programming
Introduction to Programming
Hint idea 2 Split into shorter tasks like this.
DATA TYPES AND OPERATIONS
What you need to do… Drag the pieces of code into the correct order like you can see in the EXAMPLE below. print ( “ int input ) = + Hello world chr ord.
Presentation transcript:

H446 Computer Science

03_Programming Coding challenges for information day

Basic operations

Write a program to print out the number of seconds in a 30 day month

Write a program to print out the number of seconds in a year

A high speed train can travel at an average speed of 150 mph, how long will it take a train travelling at this speed to travel from London to Glasgow which is 414 miles away? Give your answer in minutes

If you are going on holiday to France how many Euros would you get when you convert £500 at an exchange rate of £1 = €1.20 ?

On return from your holiday you now have €320, how much GBP would you receive at an exchange rate of £1 = €1.32?

Insert brackets in the expression 36/9-2 to get: a) 2 b) 5.12

Variables

Write a program that assigns the variables length and width to be 18 and 7 respectively. Use the variables to calculate the perimeter and area of a rectangle

The volume of a sphere is given by V = (4/3)pi The volume of a sphere is given by V = (4/3)pi*r^3, use python to find the volume of a sphere with a radius of 10 cm

Write a python program that defines a variable called daysInEachSchoolYear and assign 192 to this variable. The program should then print out the total hours that you spend in school from year 7 to year 11, assuming that you spend 6 hours at school each day

What is the output after running the following code. score = 24 What is the output after running the following code? score = 24 numberOfPieces = 2 newScore = score *2 print(newScore)

True or false – an expression can be assigned to a variable?

Data types

Write a program that stores your favourite quotation in a variable called quote

What is the data type of donkey in the code snippet below. donkey = 34

Define a variable called name that assigns your name to it

Write a program that asks the user for three numbers and outputs the sum

Write a program that will ask the user for their name and age and output this back to the screen with a nice message

What letter will be printed on the screen after running the following code? title="Python for key stage 4" letter = title[3] print(letter)

What will the following code produce. title = "Python for key stage 4" What will the following code produce? title = "Python for key stage 4" for letter in title: print(letter)

Functions

Define a function called double, that takes a number and return the number doubled

Define a function called perimeterOfRectangle that takes two numbers to represent the length and width of a rectangle and returns the perimeter of the rectangle

Define a function called areaOfCircle that takes one number as an input to represent the radius, and returns the area of the circle

Control structures Selection statements and iteration

Write a program that asks the user to enter two numbers, it should use a selection statement to output the larger of the two numbers

Define a function called larger(), that takes two integers and returns the larger of the two

Write a function called printUpto() that takes a number as input and output all the whole numbers from 1 up to and including the given number

Arrays

Given the list bankHolidaysMonth = [1, 0, 1, 1, 2, 0, 0, 1, 0, 0, 0, 2] , where each element represents the number of bank holidays in a month. For example in January there is 1, in February 0, March there is 1 etc. Write a function called bankHoliday(), that takes a number to represent the month and return the number of bank holidays in that month. Example: bankHoliday(5) would return 2

Define a function called addHello(), that takes any list and append the word “hello” to the list

Define a function called sumList(), that takes a list as an input and returns the sum of all the elements in the list

A word is a palindrome if it reads the same thing in both directions A word is a palindrome if it reads the same thing in both directions. For example “civic”, “radar”, “level”, “redder”, “madam” are all palindromes. Write a function called isPalindrome(), that takes any word and returns True if the word is a palindrome or False otherwise