1 / 98

General problem solving concepts : Problem solving in everyday life,

General problem solving concepts : Problem solving in everyday life, types of problems, problem solving with computers, difficulties with problem solving problem solving aspects, top down design. Problem Solving Strategies

shina
Download Presentation

General problem solving concepts : Problem solving in everyday life,

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Generalproblemsolvingconcepts: • Problem solving in everydaylife, • typesof problems, problem solving withcomputers, • difficulties with problemsolving • problem solving aspects, top down design. Problem SolvingStrategies • ProgramDesignTools:Algorithms, Flowcharts and Pseudo-codes, implementationof • algorithms. • Basics of Python Programming: Features of Python, History and Future of Python, Writing and executing Python program, Literal constants, variables and identifiers, Data Types, Input operation, Comments, Reserved words, Indentation, Operators and expressions, Expressions inPython.

  2. What isproblem? The problem is defined as the objective or the specific output that we want to attain; through a sequence of steps and activities and, specific input.

  3. What isPAID? • A logical problem solving process can be done through some stepscalled • "PAID" • ProblemStatement • Analyze the problem indetail • Identify likelycauses • Define actualcause(s)

  4. Example problem in dailylife Students do scienceexperiment Mechanics repaira brokencar Workers goes towork Problem? Kids want eatsweets Doctors find newbacteria

  5. How to solve theproblem?

  6. Strategies • Askquestions! • WhatdoIknowabouttheproblem? • WhatistheinformationthatIhavetoprocessinorderthe find thesolution? • Whatdoes the solution look like? • Whatsortofspecialcasesexist? • HowwillIrecognizethatIhavefound thesolution?

  7. Problem SolvingDefinition A Systematic approach to defining problem(question or situation thatpresents uncertainty or difficulty) and creating a vast number of possible solutions without judging thesesolutions.

  8. Problem SolvingDefinition A Systematic approach to defining problem and creating a vast number ofpossiblesolutions without which will gives maximumaccuracy.

  9. Problem Solving in Everyday Life There are six step inproblemsolving:

  10. Problem Solving in EverydayLife Can Iskip thestep? According to Sprankle and Hubbard (2012), if the six step not completed well, theresult may be less thandesired

  11. Exampleproblems… Baking a cake according to certain specifications, input available are the ingredients (such as eggs, flour, milk …etc.), then followed by activities or procedures that should be done sequentially, taking into consideration that any mistake happens by doing any procedure before the other, results in an unsuitable and undesirablecake. List instructions that enable you to solve the problem Understand the problem Evaluate the solution Identifythe problem Identify alternative Selectthe best way

  12. Problem Solving withComputers Definitions by Sprankle& Hubbard(2012) : Set of instructionsfor solution using computer language instructions followed to producebest result Outcome OR completed computer- assistedanswer

  13. Difficulties with ProblemSolving Lack of problem solving experience Inadequate solution steps Incorrect problem definition Alternatives chosen incorrectly Incorrect solution evaluation Invalidlogic

  14. GroupActivities In in group of 4 persons, think a problems in your daily life at home, office, park, school, shopping mall or wherever your go.Please explain how you solve the problem using the six steps of problemsolving.

  15. Problem Solving withComputer • Two methodologies used to develop computer solutions to aproblem • Top-down design focuses on the tasks to bedone • Object-oriented design focuses on the data involved in the solution • But first, let's look at a way to express algorithms: pseudocode

  16. Top-DownDesign Top-DownDesign Problem-solving technique in which the problem is dividedinto Subproblems; the process is applied to eachsubproblem. Modules Self-contained collection of steps, that solve a problem orsubproblem. AbstractStep An algorithmic step containing unspecifieddetails. ConcreteStep An algorithm step in which all details arespecified

  17. A GeneralExample Planning a largeparty Subdividing the partyplanning

  18. Programmingbasics • code or source code: The sequence of instructions in aprogram. • syntax: The set of legal structures and commands that can be used in aparticular • programminglanguage. • output: The messages printed to the user by aprogram. • console: The text box onto which output isprinted. • – Some source code editors pop up the console as an externalwindow, and • others contain their own consolewindow.

  19. What isPython? • Python is a general purpose interpreted interactive object orientedand • high level programminglanguage. • Itwasfirstintroducedin1991byGuidovanRossum,aDutch computerprogrammer. • The language places strong emphasis on code reliability and simplicity so that the programmers can develop applicationsrapidly

  20. contd.. • Python is multi-paradigm programming language ,which allows user to code in several different programmingstyles. • Python supports cross platform development and is availablethrough • open source. • Python is widely used for scripting in Game menu applications effectively.

  21. History ofPython • Python is created by Guido Van Rossum in the1980s. • Rossum published the first version of Python code (0.9.0) in February 1991 at the CWI(Centrum • Wiskunde & Informatics) in the Netherlands ,Amsterdam. • Python is derived from ABC programming language, which is a general-purposeprogramming • language that had been developed at theCWI. • Rossum chose the name "Python", since he was a big fan of Monty Python's FlyingCircus. • Python is now maintained by a core development team at theinstitute, • although Rossum still holds a vital role in directing itsprogress.

  22. Why do people usePython…? The following primary factors cited by Python users seem to be these: Pythonisobject-orientedStructuresupportssuchconceptsas polymorphism, operation overloading, and multipleinheritance. Indentation is one of the greatest future inPython. It's free (opensource) Downloading and installing Python is free and easy Source code is easily accessible

  23. It'spowerful • Dynamic typing • Built-in types andtools • Libraryutilities • Third party utilities (e.g. Numeric, NumPy,SciPy) • Automatic memorymanagement • It'sportable • Python runs virtually every major platform usedtoday • As long as you have a compatible Python interpreterinstalled, • Python programs will run in exactly the same manner, irrespective of platform.

  24. PythonVersions • Release dates for the major and minorversions: • Python 1.0 - January1994 • Python 1.5 - December 31,1997 • Python 1.6 - September 5,2000 • Python 2.0 - October 16,2000 • Python 2.1 - April 17,2001 • Python 2.2 - December 21,2001 • Python 2.3 - July 29,2003 • Python 2.4 - November 30,2004 • Python 2.5 - September 19,2006 • Python 2.6 - October 1,2008 • Python 2.7 - July 3,2010 • Release dates for the major and minorversions: • Python 3.0 - December 3,2008 • Python 3.1 - June 27,2009 • Python 3.2 - February 20,2011 • Python 3.3 - September 29,2012 • Python 3.4 - March 16,2014 • Python 3.5 - September 13,2015

  25. Python CodeExecution Python’s traditional runtime execution model: source code you type is translated to byte code, which is then run by the Python Virtual Machine. Your code is automatically compiled, but then it isinterpreted. Source code extension is.py Byte code extension is .pyc (compiled pythoncode)

  26. Your FirstProgram • To develop the Python program ,click on the File and selectNewFile. • This will open a new text editor where you can write your firstprogram. • # Prints the words HelloPython • print(“HelloPython”) • print(“Its nice learningPython”) print(“Python is easy tolearn”)

  27. Data types inPython • Every value in Python hasa datatype. Since everything is anobject in Python programming, data types are actually classes and variables areInstance(object) of theseclasses. • There are various data types in Python. Some of the important typesarelistedbelow. • PythonNumbers • Integers, floating point numbers and complex numbers falls under Python numbers category. They are defined as int, float and complex class inPython. • We can use the type() function to know which class a variable or a value belongs to and the isinstance() function to check if an object belongs to a particularclass.

  28. Example >>>a=5 print(a, "is of type",type(a)) >>>a=2.0 print(a, "is of type",type(a)) >>>a=1+2j print(a, "is complex number?",isinstance(1+2j,complex))

  29. Datatype: PythonList List is an ordered sequence of items. It is one of the most used datatype in Python and is very flexible. All the items in a list do not need to be of the sametype. Declaring a list is pretty straight forward. Items separated bycommas are enclosed within brackets []. >>> a = [1, 2.2, 'python'] We can use the slicing operator [ ] to extract an item or a range of items from alist. Index starts form 0 in Python.

  30. Example a=[5,10,15,20,25,30,35,40] # a[2] =? print("a[2] =",a[2]) # a[0:3] =? print("a[0:3] =",a[0:3]) # a[5:]= print("a[5:] =",a[5:])

  31. Datatype: PythonTuple Tuple is an ordered sequence of items same aslist. The only difference is that tuples are immutable. Tuples oncecreated cannot bemodified. Tuples are used to write-protect data and are usually faster than list as it cannot changedynamically. It is defined within parentheses () where items are separated bycommas. >>>t =(5,'program',1+3j) We can use the slicing operator [] to extract items but we cannot change itsvalue.

  32. Example t = (5,'program',1+3j) # t[1] =? print("t[1] =",t[1]) # t[0:3] =? print("t[0:3] =",t[0:3]) #Generateserror #Tuples are immutablet[0]=10

  33. Datatype: PythonStrings String is sequence of Unicode characters. We can use single quotes or double quotes to represent strings. Multi-line strings can be denoted using triple quotes, ''' or""". >>>s ="This is astring" >>>s ='''amultiline Like list and tuple, slicing operator [ ] can be used with string. Strings are immutable.

  34. Example s ='Hello world!’ #s[4]=? print("s[4] =",s[4]) #s[6:11]=? print("s[6:11] =",s[6:11]) #Generateserror #Strings are immutable in Python s[5]=?

  35. Decision ControlStatements: Decision controlstatements • Selection/conditional • statements. branchingStatements:if,if-else, nested if, if-elif-else • Basicloop Structures/Iterativestatements:whileloop,forloop,selecting appropriate loop. Nested loops, The break, continue, pass, else statement used with loops.

  36. Decision ControlStatements • Decision making statements in programming languages decides the direction offlow • of programexecution. • In our daily life we do many things which depends on some kind of conditions fore.g. • If I study I will pass exams. If he is hungry he will eatetc. • Sometimes in the program, we need the statement to execute under some condition like if the value is equal to this, then this will happen and if not equal to this then this willhappen. • This can be achieved in Python by using the Decision Control statements inpython.

  37. Decision ControlStatements • We have the two types of Control statement inPython: • Decision ControlStatement: • If, If..else,if…elif….else. • Flow ControlStatement: • for, while break,continue

  38. IFStatement The If the statement is similar to other languages like in Java, C, C++, etc. It is used when we have to take some decision like the comparison between anything or to check the presence and gives us either TRUE orFALSE. The syntax for IF Statement isas: if(expression): #code to be executed under the condition statement1 statement2

  39. IF StatementExample var1=10 var2=12 if var2>var1: #here it return the TRUE value hence the if block isexecuted print( var2,'is greater then',var1) if var1>var1: #here it return the FALSE value hence the if block is notexecuted print(var1,'is smaller than',var2) print('statment after the false return inif(var1>var2)')

  40. IF…elseStatement The else statement can be used with the if statement. It usually contains the code which is to be executed at the time when the expression in the if statement returns the FALSE. There can only be one else in the program with every single ifstatement It is optional to use the else statement with if statement it depends on yourcondition. The syntax for If….Else Statement is as: if (expression): #body ofif statement1 statement2 else: #body of else statement1 statement2

  41. IF…else StatementExample var1=10 var2=12 if var2>var1: print( var2,'is greater then',var1) else: #it is not executed because the if expression is ture print(var2,'is samller then',var1) if var1>var2: print(var1,'is greater than',var2) else: #it is executed because if expresion isfalse print(var1, 'is samller then',var2)

  42. The ElifStatement The elif statement in the Python is used to check the multiple expression for TRUEand execute a block of code as soon as one of the conditions returns toTRUE. elif – is a keyword used in Python in replacement of else if to place anothercondition in the program. This is called chainedconditional. Chained conditions allows than two possibilities and need more than twobranches. The syntax for elif Statement isas: if expression: #body to be executed inif statement1 elif #body to be executed inelif statement1 else #body to be executed inelse statement1

  43. The Elif StatementExample age1 =15 #check your age #age1=12 #age1=19 if age1 <12: #executed when the age1=12 print('my age is ',age1) elif (age1 >=12) and (age1 <18): #executed when the age1=15 print('my age is ',age1) else: #executed when the age1=19 print('my age is ',age1)

  44. Python Nested ifExample #In this program, we input anumber #check if the number is positiveor #negative or zero anddisplay #an appropriatemessage #This time we use nestedif num =float(input("Enter a number: ")) if num>=0: if num ==0: print("Zero") else: print("Positivenumber") else: print("Negativenumber")

  45. Example: largest among threenumbers a =int(input(“Enter 1st number:”)) b=int(input(“Enter 2nd number:”)) c= int(input(“Enter 3rd number:”)) if (a > b) and (a>c): print("a is greater") elif (b <a) and (b <c ): print(“b is greater") else: print(“c isgreater")

  46. CONTROL STATEMENT (LoopingStatement) • Program statement are executed sequentially one after another. In somesituations, a • block of code needs oftimes. • These are repetitive program codes, the computers have to perform to complete tasks. The following are the loop structures available inpython. • whilestatement • for loopstatement • Nested loopstatement

More Related