Program Development Overview An Introduction so that Python

 www.phwiki.com

 

The Above Picture is Related Image of Another Journal

 

Program Development Overview An Introduction so that Python

Elmhurst College, US has reference to this Academic Journal, An Introduction so that Python Dr. Nancy Warter-Perez April 15, 2004 Overview Overview of program development Python Basics Python Types in addition to Operators Numbers in addition to Arithmetic operators Strings Lists Dictionaries Input & Output Example amino acid search program Programming Workshop #1 Programming Language in addition to Development Software In this program, we?ll use Python Interpretive Language Development software IDLE python gui Pythonwin (recommended) Do your work on either the hard disk or zip disk (not floppy disk, A: drive ? too slow!)

 Green, Marilyn Elmhurst College www.phwiki.com

 

Related University That Contributed for this Journal are Acknowledged in the above Image

 

Program Development Problem specification Algorithm design Test by hand Code in target language Test code / debug Program Problem solving Implementation Python Basics – Comments Python comments # line comment Header comments #Description of program #Written by: #Date created: #Last Modified: Python Basics – Variables Python variables are not ?declared?. To assign a variable, just type: identifier=literal Identifiers Have the following restrictions: Must start alongside a letter or underscore (_) Case sensitive Must consist of only letters, numbers or underscore Must not be a reserved word (LP pg 137) Have the following conventions: All uppercase letters are used in consideration of constants Variable names are meaningful ? thus, often multi-word Convention 1: alignment_sequence Convention 2: AlignmentSequence Python specific conventions: Avoid _X, __X__, __X, _, (LP pg 138)

Numbers Numbers Normal Integers ?represent whole numbers Ex: 3, -7, 123, 76 Long Integers ? unlimited size Ex: 9999999999999999999999L Floating-point ? represent numbers alongside decimal places Ex: 1.2, 3.14159,3.14e-10 Octal in addition to hexadecimal numbers Ex: O177, 0x9ff, Oxff Complex numbers Ex: 3+4j, 3.0+4.0j, 3J Python Basics ? arithmetic operations + add – subract * multiply / divide % modulus/remainder y=5; z=3 x = y + z x = y ? z x = y * z x = y / z x = y % z x = 8 x = 2 x = 15 x = 1 x = 2 Operators Example Python Basics ? arithmetic operations << shift left >> shift right ** raise so that power y=5; z=3 x = y << 1 x = y >> 2 x = y ** z x = 10 x = 1 x = 125 Operators Example

Informed search algorithms Material Outline Review: Tree search Best-first search Romania alongside step costs in km Greedy best-first search Greedy best-first search example Greedy best-first search example Greedy best-first search example Greedy best-first search example Properties of greedy best-first search A* search A* search example A* search example A* search example A* search example A* search example A* search example Admissible heuristics Optimality of A* (proof) Optimality of A* (proof) Consistent heuristics Optimality of A* Properties of A$^*$ Admissible heuristics Admissible heuristics Dominance Relaxed problems Local search algorithms Example: n-queens Hill-climbing search Hill-climbing search Simulated annealing search Properties of simulated annealing search Local beam search Genetic algorithms Genetic algorithms Genetic algorithms

Python Basics ? Relational in addition to Logical Operators Relational operators == equal !=, <> not equal > greater than >= greater than or equal < less than <= less than or equal Logical operators in addition to in addition to or or not not Python Basics ? Relational Operators Assume x = 1, y = 4, z = 14 Python Basics ? Logical Operators Assume x = 1, y = 4, z = 14 Strings Enclosed in single or double quotes Ex: ?Hello!? , ?Hello!?, ?3.5?, ?a?, ?a? Sequence of characters: mystring=?hello world!? mystring[0] -> ?h? mystring[1] -> ?e? mystring[2] -> ?l? mystring[-1] -> ?!? -1 is last, -2 next so that last, etc? String operations Strings (2) substrings can be reassigned: mystring=?spoons? mystring[5]=?!? mystring -> ?spoon!? slicing: mystring[2:] -> ?oon!? mystring[:3] -> ?spo? #note last element is never included! mystring[1:3]-> ?po?

Strings (3) ?%? operator: sort of ?fill in the blanks? operation: mystring=?%s has %n marbles? % (?John?,35) mystring -> ?John has 35 marbles? %s replace alongside string %n,%i replace alongside integer %f replace alongside float Lists Tuples Tuples ? sequence of values like lists, but cannot be changed after it is created mytuple=(1,2,3,4) mytuple=(1,?a?,?bc?,3,87.2) mytuple[1]=?3? Used when you want so that pass several variables around at once

Dictionaries Dictionaries ? map ?keys? so that ?values? like lists, but indices can be of any type Also, keys are in no particular order Eg: mydict={?b?:3, ?a?:4, 75:2.85} mydict[?b?] -> 3 mydict[75] -> 2.85 mydict[?a?] -> 4 Dictionaries Dictionaries ? other considerations Slicing not allowed Referencing invalid key is an error: >>> mydict={8.5: 8, ‘a’: 75, ‘r’: 1, ‘g’: 2, ‘y’: 3.5, 9: ‘nine’} >>> mydict[“red”] Traceback (most recent call last): File “”, line 1, in ? KeyError: ‘red? Use mydict.get(?red?) instead, it returns None if key is not found

Input/Output Function raw_input() designed so that read a line of input from the user 1 optional argument: string so that prompt user If int or float desired, simply convert string: int(mystring)->convert so that int (if possible) float(mystring)->convert so that float (if possible) >>> mystr=raw_input(“Enter a string:”) Enter a string:Hello World! >>> mystr ‘Hello World!’ Output Function print Prints each argument, followed by space After all arguments, prints newline Put comma after last arg so that prevent newline ?add? strings so that avoid spaces print ?a?,?b?,?c? a b c print ?a?,?b?,?c?, a b c print ?a?+?b?+?c? abc Output Example >>> print “hello”,”world”;print “hello”,”again” hello world hello again >>> print “hello”,”world”,;print “hello”,”again” hello world hello again >>> print “hello %s world” % “cold in addition to cruel” hello cold in addition to cruel world >>> print “hello”,”cold”+ ” ” + “and”,”cruel”,”world” hello cold in addition to cruel world

Creating a Python Program Enter your program in the editor Notice that the editor has a color coding Comments Key words Etc? Also notice that it automatically indents Don?t override!! ? this is how python tells when block statements end! If doesn?t indent so that proper location ? indicates bug Running your Program To build your program Under File->Run? Select No Debugging in the drop-down window Fix any errors, then run again Programming Workshop #1 Write a Python program so that compute the hydrophobicity of an amino acid Program will prompt the user in consideration of an amino acid in addition to will display the hydrophobicity

Green, Marilyn Morning Anchor

Green, Marilyn is from United States and they belong to Morning Anchor and work for KVOA-TV in the AZ state United States got related to this Particular Article.

Journal Ratings by Elmhurst College

This Particular Journal got reviewed and rated by Creating a Python Program Enter your program in the editor Notice that the editor has a color coding Comments Key words Etc? Also notice that it automatically indents Don?t override!! ? this is how python tells when block statements end! If doesn?t indent so that proper location ? indicates bug Running your Program To build your program Under File->Run? Select No Debugging in the drop-down window Fix any errors, then run again Programming Workshop #1 Write a Python program so that compute the hydrophobicity of an amino acid Program will prompt the user in consideration of an amino acid in addition to will display the hydrophobicity and short form of this particular Institution is US and gave this Journal an Excellent Rating.