logo Hurry, Grab up to 30% discount on the entire course
Order Now logo

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Bimla RastogiResume writing
(5/5)

831 Answers

Hire Me
expert
Lee MackEconomics
(5/5)

765 Answers

Hire Me
expert
Elizabeth BachStatistics
(5/5)

673 Answers

Hire Me
expert
Vishal FogatComputer science
(5/5)

913 Answers

Hire Me
Python Programming
(5/5)

Fix the indenting and run the program to prove it works. Screen Capture #1

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

Assignment 2 – Writing Programs

Python Intro

We need to cover some basic Python skills before getting started.

Indenting

Unlike most other programming, indenting (typically 4 spaces) matters in python.

1. Code the following

a. You’ve seen the print() statement and can probably logic through most of the code but if not, don’t worry about it, just note the error due to improper indenting

2. Fix the indenting and run the program to prove it works. Screen Capture #1 (2 point)

While it is not imperative you understand all the syntax that made up this app, there are a few things you should be aware of:

• Each line of our app is called a statement and each statement performs a task.

• The first line of the app is called the shebang line and it starts with the hash (#) and bang (!) and is used to identify which interpreter to use.

o It is not required in Windows apps but is considered good practice.

Comments

• Comments start with the # symbol and are ignored by the compiler.

a. The # can be used to comment out a full line or inline to comment out everything after the # symbol.

• Comments are used to document what a portion of the code does.

3. Add the following comments: Screen Capture #2 (2 point)

Functions

Functions are pieces of reusable code that performs a specific task. There are built-in functions, like the print() and input() and you can also create user defined functions.

We’ll be creating our own later but for now we’ll just work with some of the built-in functions.

Variables and Data Types

We use variables to store data and you might not have realized but we’ve already been using variables throughout this assignment. In our example, random_number, your_guess and count are all variables that we use to hold values we’ll later use in our application.

Unlike most popular languages today, Python is known as “Dynamically Typed”. What that means is in languages like C#, Java, etc., when variables are created, they are created with a data type (i.e. string, whole number, decimal number, boolean, etc.). But Python is different as in our previous example, we just created the variables and the data type gets set when we assign a value to it. On top of that, it’s possible for the variable to change data type based on the assignment.

4. Code as follows:

a. type() is a Python function that returns the data type if a variable Screen Capture #3 (1 point)

Naming Variables

Python has rules for naming variables:

• Must begin with a letter or underscore

• Can’t contain spaces, punctuation, or special characters other than the underscore

• Can’t begin with a number, but can have numbers in the name

• Can’t be the same as a Python reserved keyword.

Additionally, there are recommendations for naming Python variables.

• Start with lowercase letters

• Use underscore notations or camel case. (i.e. camel_case or camelCase)

• Use meaningful names

• Don’t use Python built-in names (i.e. type(), print(), etc.)

(5/5)
Attachments:

Related Questions

. The fundamental operations of create, read, update, and delete (CRUD) in either Python or Java

CS 340 Milestone One Guidelines and Rubric  Overview: For this assignment, you will implement the fundamental operations of create, read, update,

. Develop a program to emulate a purchase transaction at a retail store. This  program will have two classes, a LineItem class and a Transaction class

Retail Transaction Programming Project  Project Requirements:  Develop a program to emulate a purchase transaction at a retail store. This

. The following program contains five errors. Identify the errors and fix them

7COM1028   Secure Systems Programming   Referral Coursework: Secure

. Accepts the following from a user: Item Name Item Quantity Item Price Allows the user to create a file to store the sales receipt contents

Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip

. The final project will encompass developing a web service using a software stack and implementing an industry-standard interface. Regardless of whether you choose to pursue application development goals as a pure developer or as a software engineer

CS 340 Final Project Guidelines and Rubric  Overview The final project will encompass developing a web service using a software stack and impleme