Free Essay

Python

In: Computers and Technology

Submitted By elizmainwar
Words 1079
Pages 5
Algorithm/Pseudocode

Print all options available to user
Call the main function Ask which option user wants to choose If statement to ensure a capital or lower case “A’ will work Insert a try statement in order to catch exceptions Insert a while loop in order to keep program going until user is finished. Call the write_int_rates function Call the customerNumber function Call the CalculateBonusInterest function Ask if user wants to continue Insert an except statement to print out any errors.

If statement to ensure a capital or lower case “S” will work User is choosing the ‘search’ option Insert a try statement to catch exceptions Insert a while loop to keep program going until user enters “N” Set Boolean flag (found = False) Search = user inputs CID Open the Customer.txt file to read it Read the first line (CID) Insert a while loop to stop reading at the end of that customer’s details. Read the rest of the file for that customer Strip the newline characters If CID == search: Print all results of search Read the next CID Close the file Check if user wants to keep going Insert except statement

If statement to ensure a capital or lower case “U” will work Insert a try statement While loop to check when user wants to stop Open a temporary file Set Boolean flag Search for CID Open file, ‘Customer.txt’ Read first line of file While statement to ensure only that customer’s details are read. Read rest of file. Strip the newline characters If/else statements for SCF taken from collectAccountInfo function so savings, etc can be returned Call functions from collectAccountBalance onwards from CalculateBonusInterest function Set Boolean flag to True If found print results Else print item not found Close the temporary file Close the old file Remove the old file Rename the new file with old file name Ask if user wants to continue Insert an except statement. Quit option If statement to ensure a “Q” or a “q” will work Print “Goodbye”

Define the customerNumber function: User to input CID, while loop to ensure it has 4 digits. Return CID
Define the collectAccountInfo function: User to input whether each customer has each account and these to be passed as Boolean variables(True/False) in order that user only has to deal with which accounts customer has. Insert input validation loop to ensure user puts in information about at least one account. Return Boolean variables.
Define the collectAccountBalance function: User must input the balance of each account held by customer. This information is then displayed. Use of the Boolean variables to ensure user is not prompted for input on accounts customer does not hold. Return account balances.
Define AccountInterest function: Calculates how much interest is earned on each individual account. Displays this information and returns it.
Define the TotalAccountInterest function: Uses an accumulator to calculate the total interest and then displays total interest. It then uses Boolean variables to calculate and how much each account is holding with balance plus interest. Return the total interest..
Define the bonusInterest function: If total interest is between 61 and 370, calculate bonus interest at 15 cents for every dollar over $60. If interest is between 371 and 800, calculate bonus interest at 30 cents for every dollar over $360 plus $45 If interest earned is between 801 and $1800, calculate bonus interest at 37 cents for every dollar over $800 plus $175. If interest earned is over $1800, calculate bonus interest at 45 cents for every dollar over $1800, plus $545.
Define the TotalAmount function total_amount = s_bal + c_bal + f_bal + IS + IC + IF + bonus_interest return total_amount
Define writeToCustomerFile2/writeToCustomerFile functions Pass all information to this function in order write it to Customer.txt file

Define displayInfo function Pass all information to this function in order to print and display

Call the main function.

|Enter CID |1111 |To ensure the program continues |Please enter information for |Please enter information for |
| | | |THREE accounts |THREE accounts |
| | | | | |
|Enter 1 or 0 for |Savings: 1 |Give the Boolean “True” for each account to |Enter balance of savings |Enter balance of savings |
|each account |Current: 1 |check if each is giving the correct output |account |account |
| |Fixed Term: 1 | | | |
|Enter account |Savings: 1 |To put in data which is easily calculated by |1111 |1111 |
|balances |Current: 1 |the tester to ensure the program is working |Account Info = 111 |Account Info = 111 |
| |Fixed Term: 1 |correctly. |Savings Account Balance = 1 |Savings Account Balance = 1 |
| | | |Current Account Balance = 1 |Current Account Balance = 1 |
| | | |Fixed Term account Balance = 1 |Fixed Term account Balance = 1|
| | | |Savings Account interest = |Savings Account interest = |
| | | |0.08 |0.08 |
| | | |Current Account interest = |Current Account interest = |
| | | |0.05 |0.05 |
| | | |Fixed Term Account interest = |Fixed Term Account interest = |
| | | |0.12 |0.12 |
| | | |Total interest for all accounts|Total interest for all |
| | | |= 0.25 |accounts = 0.25 |
| | | |Bonus interest = 0 |Bonus interest = 0 |
| | | |Final total = 3.25 |Final total = 3.25 |
|Option S |S |To check if search option is working |1111 |1111 |
|Enter CID | |correctly |Account Info = 111 |Account Info = 111 |
| |1111 | |Savings Account Balance = 1 |Savings Account Balance = 1 |
| | | |Current Account Balance = 1 |Current Account Balance = 1 |
| | | |Fixed Term account Balance = 1 |Fixed Term account Balance = 1|
| | | |Savings Account interest = |Savings Account interest = |
| | | |0.08 |0.08 |
| | | |Current Account interest = |Current Account interest = |
| | | |0.05 |0.05 |
| | | |Fixed Term Account interest = |Fixed Term Account interest = |
| | | |0.12 |0.12 |
| | | |Total interest for all accounts|Total interest for all |
| | | |= 0.25 |accounts = 0.25 |
| | | |Bonus interest = 0 |Bonus interest = 0 |
| | | |Final total = 3.25 |Final total = 3.25 |
|Option U |U |To check if Update option working correctly |Enter balance of savings |Enter balance of savings |
| | | |account |account |
|Enter CID |1111 | | | |

Test Data

|Enter Account |Savings: 2 |To check if details will update |1111 |1111 |
|balances for |Current: 2 | |Account Info = 111 |Account Info = 111 |
|updating |Fixed-term: 2 | |Savings Account Balance = 2 |Savings Account Balance = 2 |
| | | |Current Account Balance = 2 |Current Account Balance = 2 |
| | | |Fixed Term account Balance = 2 |Fixed Term account Balance = 2 |
| | | |Savings Account interest = |Savings Account interest = |
| | | |0.16 |0.16 |
| | | |Current Account interest = 0.1|Current Account interest = 0.1|
| | | |Fixed Term Account interest = |Fixed Term Account interest = |
| | | |0.24 |0.24 |
| | | |Total interest for all accounts|Total interest for all accounts|
| | | |= 0.5 |= 0.5 |
| | | |Bonus interest = 0 |Bonus interest = 0 |
| | | |Final total = 6.50 |Final total = 6.50 |
|Enter “Q: for |“Q” or “q” |To check program will terminate |“Goodbye” |“Goodbye” |
|quit option | | | | |

:

Similar Documents

Free Essay

Python Programming

...Introduction to Programming with Python 1 Outline Introduction to Python Operators & Expressions Data Types & Type Conversion Variables: Names for data Functions Program Flow (Branching) Input from the user Iteration (Looping) 2 What is Python  Python is both an interpreted, general purpose, open source, cross-platform, high level programming language.  Python uses an interpreter. This is a software program that convert Python code to machine language.  It is easy to jump in and experiment with Python in an interactive fashion. Compiling and interpreting  Many languages require you to compile (translate) your program into a form that the machine understands. compile source code Hello.java  execute byte code Hello.class output Python is instead directly interpreted into machine instructions. interpret source code Hello.py output 4 Programming basics     code or source code: instructions in a program. The sequence of syntax: The set of legal structures and commands that can be used in a particular programming language. output: The messages printed to the user by a program. console: The text box onto which output is printed. 5 The Basic Pattern Most of our programs will use the basic pattern of:  Get some user input  Perform some algorithm on the input  Provide results as output Identifiers in Python    Identifiers...

Words: 3768 - Pages: 16

Premium Essay

Burmese Python In The Everglades

...Burmese Pythons Have you ever went to the everglades before? If so then you’ll realize how much Burmese pythons they’re in the Everglades. Now the first thing you’ll be thinking of is Burmese pythons not belonging here in Florida and should be in Southeast Asia where they’ve originated but here is where I get into detail about this. First off, what is a Burmese python? “The Burmese python is a magnificent and powerful animal”. “Native to the grassy marshes of Southeast Asia”, capable of growing to an astounding length of 23 feet and a weight of up to 200 pounds”. (Paragraph 1 of Burmese Python: The Snake That’s Eating Florida). Also Burmese pythons are carnivores and survive by eating small birds and mammals. Although they got no venom, they kill their prey by grabbing the prey with its back teeth and when the prey tries to run, it only sinks further into the python’s grip and then the python wraps its body around the body and squeeze until the animal is dead which then the python swallows the prey by its unique hinged jaws which allows it to swallow an object five times as wide as its own head....

Words: 577 - Pages: 3

Premium Essay

Burmese Python Effect

...Feeling the Squeeze: The effects of the Python molorus bivittatus (Burmese python) in South Florida Inez Broom PCB 4043 October 7, 2015   Abstract The purpose of this paper is to discuss the effects of Burmese python in their non-native environment of South Florida. The discovery of how and why they have made South Florida their home and the impact they have had on the local ecosystem will be discussed. In addition, the management and control methods being used. Introduction The Python molorus bivittatus referred to as the Burmese python originated from Southeast Asia and have made South Florida their permanent home. Burmese python have been considered a subspecies to the native Indian python and have been able to squeeze out...

Words: 1179 - Pages: 5

Premium Essay

Satire In Monty Python And The Holy Grail

...Extreme Violence of the Knights In the movie Monty Python and the Holy Grail, a group of knights, under King Arthur’s leadership, go on a quest, given to them by God, to find the Holy Grail. After a little debate, they split up, but eventually find each other again, where they approach the Bridge of Death, and after crossing, find the Grail. This movie is a significant, modern example of satire, which burlesques the knights and customs of the Middle Ages. Satire attempts to bring change in the world, without actually providing a solution. The film Monty Python and the Holy Grail uses exaggeration and unexpected logic to expose the amount of gratuitous violence that the knights employ in the Middle Ages. The scene with the brawl between...

Words: 298 - Pages: 2

Premium Essay

Monty Python Parody In Sir Gawain The Green Knight

...Monty Python parodies the medieval romances genre’s characteristics of hero-knight (bravery), the loyalty to God, and the honor and respect for all women. Monty Python parodies the medieval romances characteristic of hero-knight (bravery). In Monty Python Tim warns king Arthur about tiny creatures, in other words the tiny rabbit is really dangerous. Tim says, “ look, that rabbit’s got a vicious streak a mile wide. It is a killer!” (Python 14). The rabbit may look innocent, but is evil; however the knights charge in. The rabbit attacks them and all that is heard is the knights yelling “aaaaaugh! Run Away!” (Python 14). The knights withdrawal makes fun about their duty to be brave because they are defeated by such a tiny creature. Meanwhile in...

Words: 738 - Pages: 3

Premium Essay

Organization of Programing Languages

...or CMP 401 ASSIGNMENT | ORGANIZATION OF PROGRAMMING LANGUAGES | | ANZOTSA JOHN ALAKU | BHU/12/04/05/0042 COMPUTER SCIENCE 400 LEVEL | | | ABRSTRACT My objective for these research was to find out about different programming languages and paradigm in which they belong, the most important use in this research are text and journal by other researchers. After all studies where carried out, I came to a conclusion that one programing language can belong to more than one paradigm C++ C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. Some people say that C++ is a middle language because it has the features of high level and low-level language. As one of the most popular programming languages in the world, C++ is widely used in the software industry. C++ is also used for hardware design to analyze structure. Some of its application domains include systems software, application software, device drivers, embedded software, high-performance server and client applications, and entertainment software such as video games. AspectJ AspectJ is a general-purpose Aspect-Oriented extension to java programming language. It was created at Palo Alto Research Center Incorporated (PARC), now it is an open source project and part of the Eclipse Foundation. AspectJ has everything that Java has and more which...

Words: 3773 - Pages: 16

Free Essay

Linux Vsc

...Contents Introduction 2 The Python Programming Language 2 History of Python 2 Features 4 Advantages and Disadvantages 5 Python vs. C 5 Summary 11 Bibliography 12 Introduction After comparing several programming languages, I have found many books and websites expressing how fast and efficient Python is. Further, many research papers describe the advantages of adding Python to computer sciences classes. For this reason I decided to study this language and compare it to one that I am familiar with, like the C language. This paper contains the history of Python, from its creation until now. It shows the features that make Python so popular, and the differences between Python and other languages. Most importantly, it explains the four pillars that are the foundation of the Python programming language, which are to provide quality, increase productivity, portability, and integration. Through this paper illustrate the advantages and disadvantages of Python, by showing that, although an interpretative language such as Python will never be as fast as a compiled language like C, it will be more efficient and useful in a variety of cases. The Python Programming Language History of Python Python (Software, 2011) is a relatively recent, object-oriented, interpreted scripting language created by Guido van Rossum at Stichting Mathematisch Centrum (CVI) in the Netherlands. According to Mark Pilgrim, Python is a successor of the ABC language...

Words: 1762 - Pages: 8

Premium Essay

Java Script: What Is a Function?

...Java Script: What is a Function? Abstract Java script functions are pieces of codes used to execute commands in a program whenever they are called to do so. Java script functions enable the reusability of commands, passing argument and value return in the program. This paper discusses functions as used in Java script as a programming language. Key words: Java script, functions, Python, built-in function, programmer function Java Script: What is a Function? Introduction In Java script, functions are defined as pieces of codes with specific duties that must be called up or referenced before they perform this function. Prior to their referencing, the codes sit in a dormant mode without any function. Functions can also be defined as collection of names or value pairs with hidden links to prototype object. One major use of functions in Java script is in repetitive tasks such as calculations, thus, they highly exhibit an element of reusability. Some programmers sometime call functions as constructors or arrays. Functions are used in defining arguments passed down to them by the programmer when the function is called (Resig, 2006). The result of the argument from the function depends on the kind of arguments that are given to the function. Functions can take more than one argument. Additionally, functions allow for augmenting object prototype to be available to other functions. Augmenting a function prototype makes this method to be available to...

Words: 470 - Pages: 2

Premium Essay

Prog Research Paper Unit 1

...1970’s Dartmouth Basic- was created by John Kemeny and Thomas Kurtz on May 1, 1964. Basic stands for Beginners All-purpose Symbolic Instruction Code . The aims of the BASIC system were: to develop a system and language that was friendly, easy to learn and use, to introduce computing as an adjunct to other courses, to operate an open access policy (i-programmer.info, 2010). Pascal- was created by Niklaus Wirth in 1972. He wanted a language suitable for teaching but for teaching computer science. It is best described as a simplified version of Algol. It was simplified both to make it easier to learn and to make it easier to compile (i-programmer.info, 2010). C- Was created by Ken Thompson iin the form of B and tweaked by Dennis Ritchie and renamed C in the 1970’s. It was the original code Unix was written in. Its function was for ease of use (i-programmer.info, 2010). Forth- was created by Charles H Moore in the 1970’s. The motivation behind this language was for both interactive execution of commands and the ability to compile sequences of commands for later execution (i-programmer.info, 2010). PLEX (Programming Language for EXchanges)- was created by Goran Hemdahl at Ericsson in the 1970’s. It is a special-purpose, pseudo-parallel and event-driven real-time programming language dedicated for AXE telephone exchanges, It is a propriatary language (i-programmer.info, 2010). 1980’s Atari ST BASIC – Atari commissioned MetaComCo to write a version of BASIC that...

Words: 1761 - Pages: 8

Free Essay

Pt1420 Unit 1 Rearch Ass.1

...was the B language, which was created by Ken Thompson in 1969-70. The computers in that time wrote in assembly code and the user had to write many pages of code to do a task. When the B language was created, it made it possible to do a task in a few lines. Although the B language improved the systems it lacked use of structure and didn’t know data types. So in 1971-73 Dennis Richie wrote the C language in which he kept the B syntax but added data types and other changes that needed to be made. It was built for power and speed and developed for UNIX systems. Its also used for Windows, the MacOS and Linux. 2. 1980s – The programming language was Python, which was created by Guido van Rossum. It’s more of a scripting language and allows users to produce large quantities readable and functional code in a quick amount of time. Python teaches the user how to work with other languages, indentation, and modularity. It supports object – oriented, procedural, and functional program styles. C++ was also created and used many different types of computers. Program A was created by Arthur Whitney in 1988, and it focused on graphics, systems interfaces, utility support, and user community. 3. 1990s – The programming language was Ruby, which was created by computer scientist Yukihiro Matsumoto. It was created to have syntax without having to learn all the commands and specialized vocabulary in order to get going. Its object – oriented and supports procedural, imperative, and functional...

Words: 454 - Pages: 2

Premium Essay

Exploring Programming Languages

...1970’s Dartmouth Basic- was created by John Kemeny and Thomas Kurtz on May 1, 1964. Basic stands for Beginners All-purpose Symbolic Instruction Code . The aims of the BASIC system were: to develop a system and language that was friendly, easy to learn and use, to introduce computing as an adjunct to other courses, to operate an open access policy (i-programmer.info, 2010). Pascal- was created by Niklaus Wirth in 1972. He wanted a language suitable for teaching but for teaching computer science. It is best described as a simplified version of Algol. It was simplified both to make it easier to learn and to make it easier to compile (i-programmer.info, 2010). C- Was created by Ken Thompson iin the form of B and tweaked by Dennis Ritchie and renamed C in the 1970’s. It was the original code Unix was written in. Its function was for ease of use (i-programmer.info, 2010). Forth- was created by Charles H Moore in the 1970’s. The motivation behind this language was for both interactive execution of commands and the ability to compile sequences of commands for later execution (i-programmer.info, 2010). PLEX (Programming Language for EXchanges)- was created by Goran Hemdahl at Ericsson in the 1970’s. It is a special-purpose, pseudo-parallel and event-driven real-time programming language dedicated for AXE telephone exchanges, It is a propriatary language (i-programmer.info, 2010). 1980’s Atari ST BASIC – Atari commissioned MetaComCo to write a version of BASIC that...

Words: 1789 - Pages: 8

Free Essay

Pt1420 Unit 1 Research Ass 1

...| Exploring Programming Language | Unit 1 Research Assignment 1 | | | 5/3/2014 | PT1420 | The five most popular programming languages in the 1970’s were: 1970: Pascal 1972: C 1972: Smalltalk 1972: Prolog 1973: SQL Pascal The Pascal programming language was developed by Niklaus Wirth. It was created in 1968 but it wasn’t published until 1970. It was developed to provide the features other programming languages didn’t offer at that time. His main reason for developing Pascal was efficiently implement and run, to allow for the development of structured and well organized programs, and to serve as a tool to teach the important concepts of computer programming. The program was named after a mathematician named Blaise Pascal. It was used as the primary language in the Apple Lisa and for the Mac in the early years of the computer. SQL SQL, which is short for, Structured Query Language, was designed by an IBM research center in 1974-1975. The Oracle Corporation introduced it as a commercial database system in 1979, the first time it was introduced. It has been a favorite query language for the use of database management systems for the microcomputer and mainframes, but is being supported by the PC database. C C was created at the Bell Laboratory in 1972 by Dennis Ritchie. It was created for the purpose in designing UNIX. Prolog Was created from 1971-1973 and was distributed in 1974-1975. It was created not as a programming language on purpose but...

Words: 988 - Pages: 4

Premium Essay

Exploring Programming Languages

...Exploring Programming Languages 1970s * Pascal * Developed 1970 * originally developed by Niklaus Wirth, a member of the International Federation of Information Processing (IFIP) * principle objectives, allow for the development of well structured and well organized programs, and to serve as a vehicle for the teaching of the important concepts of computer programming * named after the mathematician Blaise Pascal * C * Developed 1972 * C was created by Dennis Ritchie at Bell Labs initially as a systems programming language for implementing UNIX * C++ was created by Bjarne Stroustrup at Bell Labs in the 1980s adding object orientation to C * Influenced ANSI C, Java * C/C++ has become the world’s most widely used systems programming language * ML * Developed1973 * Created by Robin Milner at University of Edinburgh * Initial focus: meta-language for program verification * One of the most widely used functional programming languages * Influenced Standard ML, Miranda, Haskell * SQL * Completed 1978 * First defined in 1970 by Dr. E.F. Codd, researcher for IBM, in a his Paper titled “A Relational Model of Data for Large Shared Data Banks “ * SQL would allow computer users to retrieve data from a variety of sources * Smalltalk * Released 1972 * first commercially-successful object-oriented language * Written and developed...

Words: 790 - Pages: 4

Free Essay

Program Design

...转:程序员练级之路 (作者:陈皓)作者: 吴江伟 建议: * 不要乱买书,不要乱追新技术新名词,基础的东西经过很长时间积累而且还会在未来至少10年通用。 * 回顾一下历史,看看历史上时间线上技术的发展,你才能明白明天会是什么样。 * 一定要动手,例子不管多么简单,建议至少自己手敲一遍看看是否理解了里头的细枝末节。 * 一定要学会思考,思考为什么要这样,而不是那样。还要举一反三地思考。 注:你也许会很奇怪为什么下面的东西很偏Unix/Linux,这是因为我觉得Windows下的编程可能会在未来很没有前途,原因如下:   * 现在的用户界面几乎被两个东西主宰了,1)Web,2)移动设备iOS或Android。Windows的图形界面不吃香了。 * 越来越多的企业在用成本低性能高的Linux和各种开源技术来构架其系统,Windows的成本太高了。 * 微软的东西变得太快了,很不持久,他们完全是在玩弄程序员。详情参见《Windows编程革命史》 所以,我个人认为以后的趋势是前端是Web+移动,后端是Linux+开源。开发这边基本上没Windows什么事。 启蒙入门 1、 学习一门脚本语言,例如Python/Ruby 可以让你摆脱对底层语言的恐惧感,脚本语言可以让你很快开发出能用得上的小程序。实践项目: * 处理文本文件,或者csv (关键词 python csv, python open, python sys) 读一个本地文件,逐行处理(例如 word count,或者处理log) * 遍历本地文件系统 (sys, os, path),例如写一个程序统计一个目录下所有文件大小并按各种条件排序并保存结果 * 跟数据库打交道 (python sqlite),写一个小脚本统计数据库里条目数量 * 学会用各种print之类简单粗暴的方式进行调试 * 学会用Google (phrase, domain, use reader to follow tech blogs) 为什么要学脚本语言,因为他们实在是太方便了,很多时候我们需要写点小工具或是脚本来帮我们解决问题,你就会发现正规的编程语言太难用了。 2、 用熟一种程序员的编辑器(不是IDE) 和一些基本工具 * Vim / Emacs / Notepad++,学会如何配置代码补全,外观,外部命令等。 * Source Insight (或 ctag) 使用这些东西不是为了Cool,而是这些编辑器在查看、修改代码/配置文章/日志会更快更有效率。 3、 熟悉Unix/Linux Shell和常见的命令行 * 如果你用windows,至少学会用虚拟机里的linux, vmware player是免费的,装个Ubuntu吧 * 一定要少用少用图形界面。 * 学会使用man来查看帮助 * 文件系统结构和基本操作 ls/chmod/chown/rm/find/ln/cat/mount/mkdir/tar/gzip … * 学会使用一些文本操作命令 sed/awk/grep/tail/less/more … * 学会使用一些管理命令 ps/top/lsof/netstat/kill/tcpdump/iptables/dd… * 了解/etc目录下的各种配置文章,学会查看/var/log下的系统日志,以及/proc下的系统运行信息 *...

Words: 817 - Pages: 4

Free Essay

Advantages of Phase Modulation

...Python Reference Manual Release 2.3.3 Guido van Rossum Fred L. Drake, Jr., editor December 19, 2003 PythonLabs Email: docs@python.org Copyright c 2001, 2002, 2003 Python Software Foundation. All rights reserved. Copyright c 2000 BeOpen.com. All rights reserved. Copyright c 1995-2000 Corporation for National Research Initiatives. All rights reserved. Copyright c 1991-1995 Stichting Mathematisch Centrum. All rights reserved. See the end of this document for complete license and permissions information. Abstract Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. Its high-level built in data structures, combined with dynamic typing and dynamic binding, make it very attractive for rapid application development, as well as for use as a scripting or glue language to connect existing components together. Python’s simple, easy to learn syntax emphasizes readability and therefore reduces the cost of program maintenance. Python supports modules and packages, which encourages program modularity and code reuse. The Python interpreter and the extensive standard library are available in source or binary form without charge for all major platforms, and can be freely distributed. This reference manual describes the syntax and “core semantics” of the language. It is terse, but attempts to be exact and complete. The semantics of non-essential built-in object types and of the built-in functions and modules are described in the Python...

Words: 14272 - Pages: 58