TutorsOnspot.com is a worldwide forum where we help our clients all over the world to meet the best Academic Writers.

Our Live writers provide Original paper which is 100% unique and plagiarism free. Writers always meet the all requirements of the paper and make sure it must be a quality piece of writing.

They especially take care of the Grammar, and follow the proper Referencing style which is directed by the client. Writers majorly write papers in APA, Harvard, MLA, Chicago and IEEE.

Python

PROJECT IMPLEMENTATION

This assignment will assess your problem solving and programming skills, using Python. You will be provided with a problem description that you will implement (code). You should use any feedback which you received on your first assessment to improve coding and problem-solving skills. The source code for this programming problem will be submitted through LearnJCU by the due date listed above.

Other Info

Assignment1_Jc433987_Rakshith/IPO_Rakshith.docx ASSESSMENT TASK [INSERT NUMBER] COLLEGE OF [INSERT COLLEGE] CP1401: Subject title INDIVIDUAL TASK COVER SHEET Student Please sign, date and attach cover sheet to front of assessment task for all hard copy submissions SUBJECT CODE CP1401 STUDENT FAMILY NAME Student Given Name JCU Student Number Rajendra Rakshith 1 3 3 5 2 7 3 2 ASSESSMENT TITLE TROPICAL AIR INSTRUCTION DUE DATE 5th December LECTURER NAME SHAILEY CHAWLA TUTOR NAME SHAILEY CHAWLA Student Declaration 1. This assignment is my original work and no part has been copied/ reproduced from any other person’s work or from any other source, except where acknowledgement has been made (see Learning, Teaching and Assessment Policy 5.1). 2. This work has not been submitted for any other course/subject (see Learning, Teaching and Assessment Policy 5.9). 3. This assignment has not been written for me. 4. I hold a copy of this assignment and can produce a copy if requested. 5. This work may be used for the purposes of moderation and identifying plagiarism. 6. I give permission for a copy of this marked assignment to be retained by the College for benchmarking and course review and accreditation purposes. Learning, Teaching and Assessment Policy 5.1. A student who submits work containing plagiarised material for assessment will be subject to the provisions of the Student Academic Misconduct Requirements. Note definition of plagiarism and self plagiarism in Learning, Teaching and Assessment Policy: Plagiarism: reproduction without acknowledgement of another person’s words, work or expressed thoughts from any source. The definition of words, works and thoughts includes such representations as diagrams, drawings, sketches, pictures, objects, text, lecture hand-outs, artistic works and other such expressions of ideas, but hereafter the term ‘work’ is used to embrace all of these. Plagiarism comprises not only direct copying of aspects of another person’s work but also the reproduction, even if slightly rewritten or adapted, of someone else’s ideas. In both cases, someone else’s work is presented as the student’s own. Under the Australian Copyright Act 1968 a copyright owner can take legal action in the courts against a party who has infringed their copyright. Self Plagiarism: the use of one’s own previously assessed material being resubmitted without acknowledgement or citing of the original. Student Signature … Rakshith Rajendra … Submission Date 5th December , 2019 Individual Task Cover Sheet (Version January 2017) IPO TABLE FOR main() function: Input Processing Output Name Call to the function menu() Prints a welcome message and name IPO for the def main(): def main(): name = input("What is your name?") global NAME NAME = name print("Welcome", NAME) menu() Ipo for age function : Input processing output Name, location, total fare, class and seat location Checks person’s age and based on that ticket fare is calculated Displays the ticket with details and fare def age(nAME, lOCATION, tOTAL, cLASS, sEATLOC): print("How old is the person travelling."&&"Travellers under 16 years old will receive promotion of 50% discount for the fare."). age = int(input()) if age > 0 and age < 16: tOTAL = float(tOTAL) / 2 print("Calculating Fare..") print("Ticket for: " + nAME + " LOCATION: " + lOCATION + " CLASS: " + cLASS + " SEATLOC: " + sEATLOC) print("TOTAL FARE: " + tOTAL) else: print("Calculating Fare..") print(" Ticket for: " + nAME + " LOCATION: " + lOCATION + " CLASS: " + cLASS + " SEATLOC: " + sEATLOC) print("TOTAL FARE: " + tOTAL) Ipo for menu function: Input Processing output get user choice If its I displays information if it is o displays name and if its e then display thank you Display the information or display name or display thank you for visiting the airlines. def menu(name): print("Tropical Airlines Ticket Ordering System") print("(I)nstructions /n(O)rder Ticket /n(E)xit") userchoice = input() if userchoice == "I"||userchoice == "i": print("Thank you for choosing Tropical Airlines for your air travel" + "needs.You will be asked questions regarding what type of ticket you" + "would like to purchase as well as destination information.We" + "also offer 50% discounted fares for children") else: if userchoice == "O"||userchoice == "o": order (name) else: if userchoice == "E"||userchoice == "e": print("Thank you for visiting Tropical Airlines") else: menu () Ipo for order function: Input Processing Output Name of the current passenger Get the input so as to know whether the ticket is for current user or another Get the ticket for the passanger by calling function ticket () def order(nAME): print("Ticket for (Y)ou or (S)omeone else") input = input() if input == "Y": ticket (nAME) else: print("Enter the name of the fellow passengers") newname = input() ticket (newname) Ipo for seat function: Input Processing Output Name, location, amount and class Book the seat location based on the user input(window aisle or middle) Calls the function age() def seat(nAME, lOCATION, tOTAL, var_class): print("Please choose the seat type. Choosing the middle seat will deduct 25 from the total fare") print("(W)indow 75(A)isle 50\\n(M)iddle - 25 ") input = input() if input == "W"|| input == "w": seatloc = "WINDOW - 75" tOTAL = tOTAL + 75 else: if input == "A"|| input == "a": seatloc = "AISLE - 50" tOTAL = tOTAL + 50 else: if input == "M"|| input == "m": seatloc = "MIDDLE - (-25)" tOTAL = tOTAL - 25 else: seat (nAME, lOCATION, tOTAL, var_class) age (nAME, lOCATION, tOTAL, var_class, seatloc) Ipo for seat type function: Input Processing Output Name, location and amount Gets the seat class from the user Based on the class seat() function is called def seattype(name, location, totalfare): name = name location = location tOTAL = totalfare print("Please choose the type of fare. Fees are displayed below and are in addition to the basic fare.") print("Please note choosing Frugal fare means you will not be offered a seat choice, it will be assigned to the ticketholder at travel time") input = input() if input == "B"|| input == "b": var_class = "BUSINESS - 275" tOTAL = tOTAL + 275 else: if input == "E"|| input == "e": var_class = "ECONOMY-25" tOTAL = tOTAL + 25 else: if input == "F"|| input == "f": var_class = "FRUGAL-0" else: seattype (name, location, tOTAL) seat (name, location, tOTAL, var_class) IPo for ticket function: Input Processing Output Name Gets the destination and trip type(one way or round trip) from user Based on the input from user call seattype() function def ticket(name): cALLBACK = name print("Please choose a destination and trip length. Fare choices are" + "displayed below") print("(C1) Cairns One Way – 250" + "(C2) Cairns Return – 400" + " " + "(S1) Sydney One Way – 420" + "(S2) Sydney Return – 575" + " " + "(P1) Perth One Way –510" + "(P2) Perth Return - 700") input = input() if input == "C1"|| input == "c1": lOCATION = "(C1) Cairns One Way – 250" tOTALFARE = 250 else: if input == "C2"|| input == "c2": lOCATION = "(C2) Cairns Return – 400" tOTALFARE = 400 else: if input == "S1"|| input == "s1": lOCATION = "(S1) Sydney One Way – 420" tOTALFARE = 420 else: if input == "S2"|| input == "s2": lOCATION = "Sydney Return – 575" tOTALFARE = 575 else: if input == "P1"|| input == "p1": lOCATION = "(P1) Perth One Way –510" tOTALFARE = 510 else: if input == "P2"|| input == "p2": lOCATION = "(P2) Perth Return - 700" tOTALFARE = 700 else: ticket (cALLBACK) seattype (name, lOCATION, tOTALFARE) Pseudocode: def age(nAME, lOCATION, tOTAL, cLASS, sEATLOC): OUTPUT "How old is the person travelling. Travellers under 16 years old will receive a 50% discount for the child fare." ENDFOR age <- int(input()) IF age > 0 AND age < 16: tOTAL <- float(tOTAL) / 2 OUTPUT "Calculating Fare.." OUTPUT "Ticket for: " + nAME + " LOCATION: " + lOCATION + " CLASS: " + cLASS + " SEATLOC: " + sEATLOC ENDFOR OUTPUT "TOTAL FARE: " + tOTAL ELSE: OUTPUT "Calculating Fare.." OUTPUT " Ticket for: " + nAME + " LOCATION: " + lOCATION + " CLASS: " + cLASS + " SEATLOC: " + sEATLOC ENDFOR OUTPUT "TOTAL FARE: " + tOTAL ENDIF ENDFUNCTION FUNCTION menu(name): OUTPUT "Tropical Airlines Ticket Ordering System" OUTPUT "(I)nstructions /n(O)rder Ticket /n(E)xit" userchoice <- input() IF userchoice = "I"|| userchoice = "i": ENDFOR ELSE: IF userchoice = "O"|| userchoice = "o": order (name) ELSE: IF userchoice = "E"|| userchoice = "e": OUTPUT "Thank you for visiting Tropical Airlines" ENDFOR ELSE: menu () ENDIF ENDIF ENDIF ENDFUNCTION FUNCTION order(nAME): OUTPUT "Ticket for (Y)ou or (S)omeone else" ENDFOR input <- input() IF input = "Y": ticket (nAME) ELSE: OUTPUT "ENter the name of the fellow passenger" newname <- input() ticket (newname) ENDIF ENDFUNCTION FUNCTION seat(nAME, lOCATION, tOTAL, var_class): ENDCLASS OUTPUT "Please choose the seat type. Choosing the middle seat will deduct 25 from the total fare" OUTPUT "(W)indow 75(A)isle 50\\n(M)iddle - 25 " input <- input() IF input = "W"|| input = "w": seatloc <- "WINDOW - 75" tOTAL <- tOTAL + 75 ELSE: IF input = "A"|| input = "a": seatloc <- "AISLE - 50" tOTAL <- tOTAL + 50 ELSE: IF input = "M"|| input = "m": seatloc <- "MIDDLE - (-25)" tOTAL <- tOTAL - 25 ELSE: seat (nAME, lOCATION, tOTAL, var_class) ENDIF ENDIF ENDIF ENDCLASS age (nAME, lOCATION, tOTAL, var_class, seatloc) ENDFUNCTION ENDCLASS FUNCTION seattype(name, location, totalfare): name <- name location <- location tOTAL <- totalfare OUTPUT "Please choose the type of fare. Fees are displayed below AND are in addition to the basic fare." OUTPUT "Please note choosing Frugal fare means you will not be offered a seat choice, it will be assigned to the ticketholder at travel time" input <- input() IF input = "B"|| input = "b": var_class <- "BUSINESS - 275" ENDCLASS tOTAL <- tOTAL + 275 ELSE: IF input = "E"|| input = "e": var_class <- "ECONOMY-25" ENDCLASS tOTAL <- tOTAL + 25 ELSE: IF input = "F"|| input = "f": var_class <- "FRUGAL-0" ENDCLASS ELSE: seattype (name, location, tOTAL) ENDIF ENDIF ENDIF seat (name, location, tOTAL, var_class) ENDFUNCTION ENDCLASS FUNCTION ticket(name): cALLBACK <- name OUTPUT "Please choose a destination AND trip length. Fare choices are" + "displayed below" OUTPUT "(C1) Cairns One Way – 250" + "(C2) Cairns Return – 400" + " " + "(S1) Sydney One Way – 420" + "(S2) Sydney Return – 575" + " " + "(P1) Perth One Way –510" + "(P2) Perth Return - 700" input <- input() IF input = "C1"|| input = "c1": lOCATION <- "(C1) Cairns One Way – 250" tOTALFARE <- 250 ELSE: IF input = "C2"|| input = "c2": lOCATION <- "(C2) Cairns Return – 400" tOTALFARE <- 400 ELSE: IF input = "S1"|| input = "s1": lOCATION <- "(S1) Sydney One Way – 420" tOTALFARE <- 420 ELSE: IF input = "S2"|| input = "s2": lOCATION <- "Sydney Return – 575" tOTALFARE <- 575 ELSE: IF input = "P1"|| input = "p1": lOCATION <- "(P1) Perth One Way –510" tOTALFARE <- 510 ELSE: IF input = "P2"|| input = "p2": lOCATION <- "(P2) Perth Return - 700" tOTALFARE <- 700 ELSE: ticket (cALLBACK) ENDIF ENDIF ENDIF ENDIF ENDIF ENDIF seattype (name, lOCATION, tOTALFARE) # Main ENDFUNCTION OUTPUT "What is your name?" name <- input() OUTPUT "Welcome, " + name menu (name) FLOWCHART: ------------------------------------------------EOF--------------------------------------------------------- Assignment1_Jc433987_Rakshith/sa.fprg
Revision Round Two Python Programming Major Topics Variables Input and Output Functions Conditionals – if/elif/else Iterations – while and for loops Lists Testing Professional Practices Python Variables Every variable in Python is created when it’s assigned (‘=‘) a value name = “Bob” Variable name rules No spaces No keywords (words that already have special meaning) Must start with a letter camelCase or underscores_for_spaces 3 Getting values in Python Built-in function: variableName = input(prompt) Displays prompt and then gets a value from the keyboard. This value will be stored in variableName as a string Typecast to an int or float if needed num_name = int(input(prompt)) Math Basic math can be done with numerical types (int or float) Symbols Addition is ‘+’ Subtraction is ‘-’ Division is ‘/’ Multiplication is ‘*’ Because ‘X’ already has a meaning… it is the letter ‘X’ Modulo is ‘%’ Display variables print Use ‘concatenation’ to join things together In planning and Python we use ‘+’ to indicate this: display “The sum of “ + num1 + “ and “ + num2 “ is “ + num3 We MUST explicitly insert spaces In flowgorithm use the ampersand (&) Python allows us to print a collection of things, separated by commas. It will insert spaces automatically: print(“The sum of”, num1, “and”, num2, “is”, num3) functions Keyword ‘def’ Inputs (if any) in brackets after name, separated by commas Have empty brackets if there are none Return at end (if needed) def getValue(prompt) num = int(input(prompt)) return num Calling functions If it returns a value We assign the returned value to a variable using the ‘=‘ statement: result = getResult(num1, num2) Otherwise: Just call it by name: displayResults(score) Decisions Basic keyword if Decision block structure if : Note header ends with ‘:’ as well as indentation Similar basic structure to function block Compound decisions Can combine decisions with boolean keywords: and, or, not E.g. if temp >35 and temp < 40 Each side MUST be a full decision temp > 35 and < 40 is not possible Path Condition Result Porridge is too hot Temperature > 40° Complain “It’s too hot” Porridge is too cold Temperature < 35° Complain “It’s too cold” Porridge is just right Temperature > 35° and < 40° Eat someone else’s porridge For Example… if num > 0 and num <= 10: print(“Valid Number”) if num <= 0 or num > 10: print(“Invalid Number”) More complex decisions New Keyword needed: else For the ‘false’ path And more complex again… New keyword needed: elif for each branch other than the first and last Examples if num > 0: print(“You Entered ” & num) else: print(“Invalid Number”) or if num <= : print(“Invalid Number”) else: print(“You Entered ” & num) Examples if score < 50: print(“Fail”) elif score <65: print(“Pass”) elif score <75: print(“Credit”) elif score <85: print(“Distinction”) else: print(“High Distinction”) Types of Loops Two ‘categories’ of iterations Definite (we KNOW how many times) Indefinite (no way of knowing) ‘while’ loops for indefinite ‘for’ loops for definite Can use while here too, but for makes it easier Definite also applies if the computer knows at runtime, even though we cannot predict it at writing time… 16 While loops Also know as a ‘pre-test’ loop Tests the loop condition BEFORE it runs May never run if the condition is false to start with Like decisions, an iteration ‘block’ has 2 parts Header while : Body Code within the loop, must be indented While loops Let’s implement this in Python: get value from user while value is less than zero: print an error display prompt get value display value For loops For loop header is very different Header for variable in collection: collection can be either: A range range(10) A list Names More in CP1404… For loops On the first iteration variable will have the value of the first thing in the collection On each iteration the value of variable changes to be the next value in the collection range(10) is [0,1,2,3,4,5,6,7,8,9] Up to, but not including, the stop value! for count in range(10) print(count) Will display the numbers 0,1,2,3,4,5,6,7,8 and 9 on separate lines Arrays (Lists in Python) Like any variable we create a list by giving it a value: listName = [] Creates an empty list Can give it values, separated by commas, instead of making it empty myList = [1,2,3,4,5] Creates a list of five integers 1 to 5 Iterating over a list For loops were designed to access lists, so they are our preferred method here We know the number of iterations (size of the list) Builtin function ‘len()’ can tell us this at runtime (avoids magic numbers) ‘For’ loop header can use this value 22 Examples myList = [1,2,3,4,5] for i in range(len(myList)) print(myList[i]) Iterating over a list But there is an even simpler way We can use the list itself as the container to loop over: for num in myList: print(num) Will print each value in the list  24 Testing Code Why? We (should) have already checked our design, so we know it works So why do we need to make sure the code works? We need to check that we implemented our solution correctly Testing Code How? Try running it, see what happens  If and when error messages appear READ THEM! Right now they may seem unhelpful, but we will become familiar with them over time What are we testing? That it runs Syntax errors That it gives the correct results Logic errors Are there any user inputs which break the program Runtime errors 27 Testing functions Each function should be tested individually Called ‘unit testing’ Create a simple ‘main’ which tests each function with sample input 28 Testing Decisions Each decision should be tested individually Put it in a function by itself, and test it with fixed inputs (or user input) Test ALL ‘boundary conditions’ E.g. If temp <= 35 Then We need to test this with temp = 34, 35 and 36 to ensure it behaves as we expect 29 Testing Loops Each loop should be tested individually Put it in a function by itself, and test it with fixed inputs Test the number of runs E.g. while count <= 10 Does this exit when count is 9, or 10, or 11? Does it behave as we expect? 30 Professional Practices Commenting standards Position (above/end of line) On functions Style Length Position is a style choice, some people prefer to comment on the line above, some comment at the end of the line Functions should have a comment on the line above, indicating what the function is for Style should be clear and concise Length should be as short as possible without being unclear 31 Naming Standards Valid variable names != good variable names Naming conventions Capsfirst – used for Class names We don’t use these in CP1401, but you will see them in the future. ALLCAPS – reserved for unchanging (constant) values Constants – Local and Global In Python we cannot ‘define’ constants Use ALLCAPS to indicate constancy IF a value is only used in one function it should be defined inside that function If it is used in several places it can be defined at the top of our code, outside of ALL functions (including main) as a ‘global ‘constant’ Global constants allow me to avoid passing around data which is used in several places Why is this allowed when global variables are not?

Homework Writing Help 24/7 within Minutes!!

Get Instant Essay Writing help from Live Writers on the spot at TutorsOnspot.com within 1 minute. Starting Prices are as low as $5.

TutorsOnSpot.com is a marketplace to help students with their Instant writing help with any of the subjects and class. Our online writers help you in the following:

  • Homework Writing
  • Essays Writing
  • Assignment Writing
  • Homework Writing
  • Thesis and Dissertation Writing
  • Case Study Writing

Any kind of academic assignments need in any subject or class level 5th grade to PhD

View Live Writers

Top Rated Tutor at TutorsOnSpot