CTS1133C-M03Prt01-NETLAB15
.pdf
keyboard_arrow_up
School
Florida State College at Jacksonville *
*We aren’t endorsed by this school
Course
2092
Subject
Computer Science
Date
Jun 24, 2024
Type
Pages
12
Uploaded by ChefFreedom10543
196
Complete A+ Guide to IT Hardware and Software
Lab 15.8 Introduction to Python Scripting
Objective: To create and run Python scripts using IDLE
Parts: Windows computer with access to the internet and rights to download and install free software
Procedure: Complete the following steps and answer the accompanying questions
1.
Power on the computer and log on. Open a web browser.
2.
In the browser, go to https://www.python.org. Click Downloads
> Download Python 3.10.4
. Save the
file python-3.10.4-amd64.exe
to a place on the computer where you can find it.
LAB 15:
Introduction to Scripting Labs 197
LAB
15
Note:
At the time of this writing, Python 3.10.4 was the latest version. If that has changed, you can download a later version. However, to do this lab, you must have a version of Python 3 installed (
not
Python 2!).
The executable file that you downloaded installs Python on your computer. This will allow you to create programs in the Python language, using the integrated development environment (IDE) named IDLE. (Note: IDE is a generic term for a program used by a language to write programs, and IDLE is the name of the IDE used here to write Python programs.)
3. Run the executable file and follow the prompts. Accept all the default options. If your installation is successful, you should see a verification similar to the one shown in Lab Figure 15.4.
LAB FIGURE 15.4 Successful installation of Python
4. From Windows Start, expand the Python 3.10 folder, if necessary, and click on IDLE (Python 3.10 64-bit), as shown in Lab Figure 15.5.
LAB FIGURE 15.5 IDLE (Python 3.10 64-bit) in the Start menu
198
Complete A+ Guide to IT Hardware and Software
5. You should see the IDLE Shell 3.10.4 window. This is also called the Python Shell. Make it active by clicking anywhere in its blank area. The cursor should be blinking to the right of the three chevrons: >>>
. Press ®
two times, and you should see two more rows of chevrons. This means that Py-
thon is working and waiting for you to do something.
6. In the Python Shell window, type the following:
print("I got it to work!")
Press ®
, and you should see a screen like the one shown in Lab Figure 15.6.
LAB FIGURE 15.6 Working in the Python IDLE shell
7. To prepare for your work, create a folder called PythonTest
. Make sure you know where this folder is located.
8. The Python Shell window is where you see a script run. To create a script, you need to work in the Python editor. From the menu within the Python Shell window, select File
> New File
to open the Python editor.
Type the following into the editor:
# display a greeting and generate a password
# get input from the user
first_name = input("First name: ")
last_name = input("Last name: ")
id_number = input("Enter your school ID number: ")
# create strings
name = first_name + " " + last_name
temp_password = first_name + "*" + id_number
# display the results
print("Welcome " + name + "!")
print("Your temporary password is: " + temp_password)
Be sure to type this code exactly as shown. In Python, indents, spaces, and line spacing are very important:
>
In this program, any line that begins with a hash symbol (
#
) is a comment and will be ignored by the computer when the program runs.
>
The following are the variable names in this script: first_name
, last_name
, id_number
, name
, and temp_password
. The value on the right side of the equals sign is the value stored in the variable on the left side.
LAB 15:
Introduction to Scripting Labs 199
LAB
15
>
In the line first_name = input("First name: ")
, the variable is first_name
. The word input
is a Python function that tells the computer to put a prompt on the screen. The text of the prompt is whatever is enclosed in quotes inside the parentheses. In this case, the text First name:
is displayed. When the user enters their name, that value is stored in the variable first_name
.
>
The name
variable joins the values of two variables and adds a space between those values because of the space within quotes (
"
"
).
>
The print()
command tells the computer to display something on the screen. It can be text, the value of a variable, or a combination of text and variables.
9. Save your program with the filename python1
xxx
.py
(where xxx
is your initials) inside your PythonTest
folder by going to the File
tab and selecting Save As
.
10. Now you can run your program. Go to the Run
tab at the top of the Python editor screen, as shown in Lab Figure 15.7, and click on Run Module
. The program should open in the Python shell and prompt you for your first name.
LAB FIGURE 15.7 The Run
tab in the Python IDLE editor
If you get an error, go back to the editor and compare your code with the code given above. Fix any errors you find, save the changes, and try again.
11. Nothing happens until you enter something. Enter Jackie
for the first name and enter Cho
for the last name. Enter 123456
for the school ID number. You should see the results in the Python shell, as shown in Lab Figure 15.8.
LAB FIGURE 15.8 Results of the first Python script
Did the script work? [ Yes | No ] If the script did not work, troubleshoot and edit your code as necessary until it does.
Instructor initials: _____________
200
Complete A+ Guide to IT Hardware and Software
12. Create a new Python program. Name this new file python2
xxx
.py (where xxx
is your initials). This new program will use a decision structure to decide whether a user is eligible for a 20%, 10%, or 0% discount on a purchase. In this program, the user will enter the cost of a purchase. If the purchase value is over $100.00, the discount is 20%. If the purchase value is $50.00 to $99.99, the discount is 10%. Anything under $50.00 is not eligible for a discount. The code for this program is as follows:
# prompt user for cost of purchase
cost = float(input("How much is your purchase? $ "))
# check for discount amount
if cost >= 100:
discount = cost * .20
percent = "20%"
elif cost >= 50:
discount = cost * .10
percent = "10%"
else:
discount = 0
percent = "0%"
# display the results
cost = cost - discount
print("You have received a " , percent, " discount")
print("Your final cost is $ ", cost)
13. Run the program at least three times to check that all the discount options (0%, 10%, or 20%) work. You can enter any numbers you want, but here are some suggestions for input:
105
87
50
34
If you enter 87
at the prompt, you should see the results shown in Lab Figure 15.9.
You might notice that there are some things that could be improved in this program:
>
Try entering a negative number. The program will still run, but it makes no sense to have a negative value as an input. You can fix this later as an On Your Own exercise.
>
The output shows a dollar amount but has only one decimal place where you would expect two. There are ways to deal with this issue, but they require more advanced coding, so for now, this is fine.
>
Each time you want to enter a new value, you must run the program again. By using a loop, you can allow the user to enter as many values as desired. You will add this functionality in the next step.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
ment basic file input/output methods
To verify, test, and debug any errors in the code
Module learning outcomes assessed by this coursework:
On successful completion of this assignment, students will be expected, at threshold level, to be able
LO # 5: Software development environments (editor, interpreter, debugger), and programmi
using Python programming language.
Task:
Students are required to
create
a Python program that performs customized Caesa
encryption/decryption, as follows:
A- The program should have a main menu, through which the user can choose whether he wants
to encrypt a text or decrypt it.
B- If the user chose to encrypt plaintext, he will be asked to enter his ID, which is also the name
of the input file (i.e. if student ID is 199999, then the input file name should be 199999.txt).
The user should not enter the file extension (i.e. .txt), instead, the program should append
the extension to the ID automatically.
C- The input file must contain the following information:…
arrow_forward
Python supports the following file processing modes: read-only, write-only, and read-write.
arrow_forward
There are three main types of interface
which enable us to interact with a
computer.
a) Identify the type of interface shown below
b) Explain an advantage and disadvantage of
using this type of interface
C:\WINDOWSystem32\cmd.exe
Microsoft Windows XP [Version 5.1.2600)
(C) Copyright 1985-2881 Microsoft Corp.
CINDocuments and Settings>
c) Joe is the IT manager of a medium sized
eCommerce company, Acme Ltd.
There are several hundred employees
working for the company's Head office. The
Operating System they currently use is
Microsoft Windows. Joe is keen to switch to
a Linux Operating System as he thinks it will
save money.
Is Joe correct? What are some other issues
he should consider before switching?
arrow_forward
Creating a Proxy for networking programming
Currently learning how to create a WEB proxy that connects with a client and server.
Create the skeleton code for creating a Web proxy server with necessary steps in creating the connection as wellas information in running the connections with a client and server.
The output or result that I would like to see is the skeleton code for a Web proxy server that at least hassome information in creating a WEB proxy. language done in C/C++ code
Please do not post an overall explanation of proxies and the web proxy as it is already given by geeks for geeks.
arrow_forward
Python supports the following file processing modes.
arrow_forward
please I need a python programme to help me with my question to discuss payment deatils please leave your contact info below in answer or comment
arrow_forward
Computer Science
Animated BFS (using python, networkx package)Nb:
-must be done in C (or in Python)
-write a short documentation about the code and explain how it's work and why?
arrow_forward
Information system using Python
Direction: Create a system about Vaccination Status of the Student. Where the user can add, delete and update the record. System record should contained the following info: Name, Age, Address, First Dose, Second Dose, Boooster, Status of Vaccine (Partially Vacinated, Fully Vacinated, Not Vacinated) and the total number of vaccinated and unvaccinated students.
arrow_forward
Create a working python code that can detect and count people in a classroom realtime using webcam. Show steps how to run the program.
Subj: Programming (Python)
arrow_forward
Python best practises?
arrow_forward
Question
• Computer Engineering lab
You are assigned three tasks for this weekend, first
you have to develop a script in F95 programming
language to print the statement "Hikaru Nakamura
is a top chess player" 10 times to the output
window.
arrow_forward
Help me in C#.
arrow_forward
PYTHON PROGRAMMING
arrow_forward
QUESTION 8
Which of the following are reasons why Python is popular and everyone should consider learning it?
It’s open source, free and widely available with a massive open-source community.
It’s easier to learn than languages like C, C++, C# and Java, enabling novices and professional developers to get up to speed quickly.
It’s easier to read than many other popular programming languages.
All of the above.
QUESTION 9
Which of the following Python Standard Library modules offers additional data structures beyond lists, tuples, dictionaries and sets?
sys and statistics
collections
queue
(b) and (c)
QUESTION 10
What value is produced when Python evaluates the following expression?
5 * (12.7 - 4) / 2
21
21.75
29.5
None of the above.
arrow_forward
Use the Internet to research the history of the Python programming language, and answer the following questions:• Who was the creator of Python?• When was Python created?• In the Python programming community, the person who created Python is commonly referred to as the “BDFL.” What does this mean?
arrow_forward
http://dpeled.com/calc_p.asm)1. Save the program into your ASM folder and run it.2.Write a line by line explanation (comments).3.What does the program do? What will be displayed?4. Explain the logic of the program how it achieves its purpose
arrow_forward
History
Bookmarks
Window Help
A augie.instructure.com
Of the choices, this represents the language that is most difficult for a human to read.
assembly
high-level
machine
No answer text provided.
0.5 points
An
is a reusable software component and can take the form of a date, time, audio, video, etc.
type your answer...
0.5 points
Which of the following is NOT an example of a Python Standard Library module?
math
sys
json
randomize
tv
4
MacBook Pro
Q Search or enter website name
O000
arrow_forward
San Pedro Belize Express has become the leading mode of transportation to Caye Caulker
and San Pedro and neighboring islands. The changes in travel restrictions and tracking due to
the Covid 19 has placed a demand on the company to keep better records of their
passengers.
The Company is wanting a secure ticketing system capable of keeping important and relevant
information from their customers
Create a python program that allows only authorized user to log into the system for ticketing
transactions and customer information queries
The program will accept names, phone number and SSID from User, Destination before
printing tickets granting them access to board the boat
The program should be able to print all customer and destination and price paid for
tickets(eacher customer records should be printed on different line in a list format/ table
format)
Destination,
San Pedro,
Name,
ID#
Fee
John Doe
2133
25
Billy Jean
Ricky Martin Caye Chapel 1322
Caye Caulker 3345
30
18.50
The program will…
arrow_forward
What makes a source code file, an object code file, and an executable file (or programme) different? computer science
arrow_forward
please answer right (python)
arrow_forward
C# programming
• Create a text file outside of C#• Read each record (name) from the file and• Append today’s date to a line from the text file and write to asecondary text file
arrow_forward
python program
- What is plagiarism and fabrication?
arrow_forward
c# WPF and Java!
List at least 2 ways that performing actions in WPF and Java Editor are the SAME. List at least 2 ways that performing actions in WPF and Java Editor are DIFFERENT.
arrow_forward
Computer Basics Assignment
Q1: Define the following:
| 1- File
| 2- System unit 3- Spyware
4- Hard disk
5- RAM
arrow_forward
Python strings and hardware/system setup/control-are they related?
Have you configured devices or systems using CLI or GUI? Describe?
arrow_forward
Python guidelines?
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Related Questions
- ment basic file input/output methods To verify, test, and debug any errors in the code Module learning outcomes assessed by this coursework: On successful completion of this assignment, students will be expected, at threshold level, to be able LO # 5: Software development environments (editor, interpreter, debugger), and programmi using Python programming language. Task: Students are required to create a Python program that performs customized Caesa encryption/decryption, as follows: A- The program should have a main menu, through which the user can choose whether he wants to encrypt a text or decrypt it. B- If the user chose to encrypt plaintext, he will be asked to enter his ID, which is also the name of the input file (i.e. if student ID is 199999, then the input file name should be 199999.txt). The user should not enter the file extension (i.e. .txt), instead, the program should append the extension to the ID automatically. C- The input file must contain the following information:…arrow_forwardPython supports the following file processing modes: read-only, write-only, and read-write.arrow_forwardThere are three main types of interface which enable us to interact with a computer. a) Identify the type of interface shown below b) Explain an advantage and disadvantage of using this type of interface C:\WINDOWSystem32\cmd.exe Microsoft Windows XP [Version 5.1.2600) (C) Copyright 1985-2881 Microsoft Corp. CINDocuments and Settings> c) Joe is the IT manager of a medium sized eCommerce company, Acme Ltd. There are several hundred employees working for the company's Head office. The Operating System they currently use is Microsoft Windows. Joe is keen to switch to a Linux Operating System as he thinks it will save money. Is Joe correct? What are some other issues he should consider before switching?arrow_forward
- Creating a Proxy for networking programming Currently learning how to create a WEB proxy that connects with a client and server. Create the skeleton code for creating a Web proxy server with necessary steps in creating the connection as wellas information in running the connections with a client and server. The output or result that I would like to see is the skeleton code for a Web proxy server that at least hassome information in creating a WEB proxy. language done in C/C++ code Please do not post an overall explanation of proxies and the web proxy as it is already given by geeks for geeks.arrow_forwardPython supports the following file processing modes.arrow_forwardplease I need a python programme to help me with my question to discuss payment deatils please leave your contact info below in answer or commentarrow_forward
- Computer Science Animated BFS (using python, networkx package)Nb: -must be done in C (or in Python) -write a short documentation about the code and explain how it's work and why?arrow_forwardInformation system using Python Direction: Create a system about Vaccination Status of the Student. Where the user can add, delete and update the record. System record should contained the following info: Name, Age, Address, First Dose, Second Dose, Boooster, Status of Vaccine (Partially Vacinated, Fully Vacinated, Not Vacinated) and the total number of vaccinated and unvaccinated students.arrow_forwardCreate a working python code that can detect and count people in a classroom realtime using webcam. Show steps how to run the program. Subj: Programming (Python)arrow_forward
- Python best practises?arrow_forwardQuestion • Computer Engineering lab You are assigned three tasks for this weekend, first you have to develop a script in F95 programming language to print the statement "Hikaru Nakamura is a top chess player" 10 times to the output window.arrow_forwardHelp me in C#.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education