What does this code do? def digitsum(): code goes here def diffsum():

Slides:



Advertisements
Similar presentations
If Statements, Try Catch and Validation. The main statement used in C# for making decisions depending on different conditions is called the If statement.
Advertisements

Rules of Divisibility. Divisible by 2? If the last digit is even then the number is divisible by 2. Even digits are 0, 2, 4, 6 and 8 (yes zero is even!)
Copyright 2006 by Pearson Education 1 Building Java Programs Chapter 5: Program Logic and Indefinite Loops.
1 String processing Samuel Marteck © A character in a string can be accessed by indicating its subscript, also called index. For instance, how.
11 and 6 3 and 9 2, 5, 10 and 4, 8 Divisibility Rules.
CS 116 Tutorial 5 Introduction to Python. Review Basic Python Python is a series of statements def f(p1, p2,…pn): x = 5 if x > p1: x = p1 + p2 return.
Chapter 9 IF Statement Bernard Chen. If Statement The main statement used for selecting from alternative actions based on test results It’s the primary.
Python – Making Decisions Lecture 02. Control Structures A program that only has one flow is useful but limited. We can use if statements to make these.
SWBAT to use divisibility rules for 2, 3, 4, 5, 6, 8, 9, and 10
Prime Numbers A whole number greater than 1 whose only whole number factors are 1 and itself
Type your question here. Type Answer Type your question here. Type Answer.
ITEC 109 Lecture 11 While loops. while loops Review Choices –1 st –2 nd to ?th –Last What happens if you only use ifs? Can you have just an else by itself?
1 CS 177 Week 6 Recitation Slides Review for Midterm Exam.
Math 8 - Unit 1 Square Roots and the Pythagorean Theorem A square number or perfect square is any number that is a product that forms when we multiply.
Double-Digit Addition Strategies
Reverse Subtraction Objectives:  do a subtract by adding  check your answer by adding.
Prime Numbers and composite numbers
Bell Work: Find the perimeter and area of a rectangle with a length of 12cm and a width of 9cm.
Today… Python Keywords. Iteration (or “Loops”!) Winter 2016CISC101 - Prof. McLeod1.
Quiz Title Your name goes here. Question 1 Click here for answer Click here for answer Go to question 2 Go to question 2.
Indentations makes the scope/block Function definition def print_message (): print “hello” Function usages print_message () hubo.move ()// hubo is a class.
IF Statements flowcharts and pseudocode Please open the speaker notes - they contain additional information!
♣Multiplying Decimals♣
Making Choices with if Statements
What is the fewest number of pluses and minuses you need to do this?
Click here for the answer. Click here for the answer.
Divisibility Rules Divisible by: If: Example: 2
Click here for the answer. Click here for the answer.
Click here for the answer. Click here for the answer.
Divisibility 6 and 7 are factors of 42.
BILLION HUNDRED MILLION TEN MILLION MILLION HUNDRED THOUSAND TEN THOUSAND THOUSANDHUNDREDSTENSONES
Lesson #1: Simplifying Radicals (For use with Sections 7-2 & 7-3)
Factors and Simplest Forms
Building Java Programs
Building Java Programs
In this lesson you will learn how to read and write algebraic expressions by using variables.
1.6 Solve Linear Inequalities
More Looping Structures
Trashball.
Suggested Layout ** Designed to be printed on white A3 paper.
Divisibility Rules.
Conditional and iterative statements
Math Journal Notes Unit 5.
A number is divisible by 2 (is even) if it has a ones digit of 0, 2, 4, 6, or 8 (that is, it has an even ones digit). Examples: A number is divisible by.
Hosted by Type your name here
Hosted by Type your name here
Building Java Programs
Hosted by Type your name here
Hosted by Type your name here
Hosted by Type your name here
Hosted by Type your name here
Hosted by Type your name here
Hosted by Type your name here
Hosted by Type your name here
Hosted by Type your name here
Jeopardy Hosted by.
Hosted by Type your name here
Control Flow statements
Hosted by Type your name here
Hosted by Type your name here
Hosted by Type your name here
Global Variables Created by assignment statement placed at beginning of program and outside all functions Can be accessed by any statement in the program.
Hosted by Type your name here
More Basics of Python Common types of data we will work with
Challenge Guide Grade Code Type Slides
Flow Control I Branching and Looping.
(Type Answer Here) (Type Answer Here) (Type Answer Here)
Hosted by Type your name here
Lecture 6 - Recursion.
Presentation transcript:

What does this code do? def digitsum(): code goes here def diffsum(): while True: answer = input("""Enter the number for the choice you want. 1 = Generate a list of all two digit numbers which are less than or equal to 56 and the sum of whose digits is greater than 10. 2 = Generate a list of all two digit numbers such that the number itself minus the number reversed is equal to the sum of its digits. 0 = Quit. Your choice: """) if answer == '1': digitsum() elif answer == '2': diffsum() elif answer == '0': break else: print("I dont understand. Please answer 0, 1, or 2.")