0% found this document useful (0 votes)
76 views11 pages

Applied Programming 1 Lab - Report Format

This lab aims to teach basic Python programming principles through a series of tasks involving literals, variables, data types, expressions, and unit conversions. Students build skills in syntax, functions, arithmetic operations, and programming logic to gain confidence in applying their Python knowledge creatively.

Uploaded by

Zille Huma
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
76 views11 pages

Applied Programming 1 Lab - Report Format

This lab aims to teach basic Python programming principles through a series of tasks involving literals, variables, data types, expressions, and unit conversions. Students build skills in syntax, functions, arithmetic operations, and programming logic to gain confidence in applying their Python knowledge creatively.

Uploaded by

Zille Huma
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 11

End of document

AETN2302 Applied Programming 1


Lab Report
Lab Number:
Title of the Lab:
Name of the Author:
Name of Instructor:
Date the Lab was started:
Due Date for this Report:

Mark Composition
Report 50
Code 25
Program Verification 25
Total 100
Lab Introduction:

Add a paragraph, explaining what the overall goal for this lab is (consider all part of the lab as
a whole)

This lab aims to teach basic Python programming principles, with a focus on literal, variable,
and data type manipulation. recognizing conversions between different units, variable
assignments, and mathematical calculations. Through the use of functions like `round()}, the
lab fosters critical thinking skills that enable students to go beyond the tasks offered and
further their understanding of the material. The lab's ultimate goal is to build students'
confidence in their ability to use their knowledge of Python programming creatively in a
variety of contexts while encouraging exploration and curiosity in the coding environment.

Part I

Explain briefly about the goals of this part

The objective is to introduce students to the concept of literals and variables in Python. By
performing a mathematical calculation using different data types, learning the syntax of basic
arithmetic operations. This part sets the foundation for understanding how to store and
manipulate numerical values in Python.

Plan the code:


Write in words and/or a flow chart what you want each section of your code to do

Task 1: Write a code to calculate the given formula or expression.


Task 2: Print the result to the console.
Task 3: Modify the code by adding the quotes around the expression and run the print
function to see the output.
Task 4: Modify the code by removing parenthesis and adding double quotes and check
output.

Include the code you developed

Input 1
print(4+2**4-50*(-2)/0.1+3*(5**2+8))

Input 2
print(“4+2**4-50*(-2)/0.1+3*(5**2+8)”)

Input 3
print “4+2**4-50*(-2)/0.1+3*(5**2+8)”

Include some input/output test data

Output 1
1119.0

Output 2
4+2**4-50*(-2)/0.1+3*(5**2+8)

Output 3
SyntaxError
Reflect on your work:

What errors did you come across?


During the process, it was discovered that the primary issue was contained in the grammar of the second and
third inputs. Quotations and brackets must be used appropriately in Python syntax. The expression was
misrepresented in the second input since regular double quotes were replaced with special quotations ("") in
that instance. The third input included a syntax error due to an incorrect quote around the expression and a
failure to utilize the print() function.

How did you overcome these errors?


These quotes were introduced intentionally and can be overcome by writing input in the correct format
of print function.

What new technique (function, operator, or approach) did you use?


No new techniques used but we can also use an approach that allows the inclusion of various items
within a single print() statement, making the code concise and readable.

Any other comments?


No

Part II

Explain briefly about the goals of this part

This part of the lab sets the foundation for more complex programming tasks that involve data
manipulation and dynamic variable usage. Working with the variables, understand the
dynamic nature of the variables, and perform basic operations with them.

Plan the code:


Write in words and/or a flow chart what you want each section of your code to do

Task1: Write code to create three variables: john, mary, and adam. And assign values 3, 5, and
6 to the variables, respectively.
Task2: Print the values of the variables john, mary, and adam in a formatted manner on one
line, separating each with a comma.
Task3: Create a new variable named Total_apple and assign the sum of john, mary, and adam
to Total_apple..
Task4: Print the value stored in Total_apple to the console.
Task5: Print a message indicating the total number of apples

Include the code you developed

john=3
mary=5
adam=6
print("john:",john,"mary:",mary,"adam:",adam,)
Total_apple=john+mary+adam
print(Total_apple)
print("Total number of apples:",Total_apple)

Include some input/output test data

john: 3 mary: 5 adam: 6


14
Total number of apples: 14

Reflect on your work:


What errors did you come across?
There was no specific error I faced. The code appears to be error-free

How did you overcome these errors?


the code appears to be error-free.

What new technique (function, operator, or approach) did you use?


There isn't a use of particularly advanced or new techniques. However, the code does
showcase fundamental concepts in Python programming. But an approach that allows the
inclusion of various items within a single print() statement, making the code concise and
readable.

Any other comments?


No

Part III

Explain briefly about the goals of this part

The primary goal of Part III is to learn the concept of unit conversion in programming,
emphasizing the practical application of mathematical operations and the utilization of
variables, and understand the importance of precision in output, and be encouraged to explore
and experiment with additional conversions beyond the given scenario.

Plan the code:

Write in words and/or a flow chart what you want each section of your code to do

Task 1: Write the initial code in the compiler


Task 2: Modify the code by calculating the equivalent distance in kilometers for the given
miles using the conversion factor (1 mile ≈ 1.61 kilometers).
Task 3: Write a code to calculate the equivalent distance in miles for the given kilometers
using the inverse of the conversion factor.
Task 4: Print the result of converting miles to kilometers, including the original distance in
miles, the conversion result rounded to two decimal places, and the unit label.
Task 5: Print the result of converting kilometers to miles, including the original distance in
kilometers, the conversion result rounded to two decimal places, and the unit label.

Include the code you developed

kilometers = 12.25

miles = 7.38

miles_to_kilometers = miles*1.61

kilometers_to_miles = kilometers/1.61

print(miles,"miles is", round(miles_to_kilometers,2), "kilometers")


print(kilometers,"kilometers is",round(kilometers_to_miles,2),"miles")

Include some input/output test data

7.38 miles is 11.88 kilometers


12.25 kilometers is 7.61 miles

Reflect on your work:


What errors did you come across?
This was a simple program and there didn’t appear to be any syntax or logical errors.

How did you overcome these errors?


There were no errors identified in the code for Part III. Therefore, there was no need to
overcome errors during the assessment.

What new technique (function, operator, or approach) did you use?


The use of arithmetic operations, the round() function, and formatted output with print()
contributes to effective and readable code in the context of unit conversion.

Any other comments?


No

Part IV

Explain briefly about the goals of this part

The goal of this part is to gain a proficiency in evaluating algebraic expressions, handling
variable data types, and creating code that is both accurate and maintainable.

Plan the code:

Write in words and/or a flow chart what you want each section of your code to do

Start
|
|----- Section 1: Evaluation for x = 0
| |
| |----- Initialize x with 0
| |----- Convert x to float
| |----- Evaluate expression 3x^3 - 2x^2 + 3x - 1
| |----- Print result y
|
|----- Section 2: Evaluation for x = 1
| |
| |----- Initialize x with 1
| |----- Convert x to float
| |----- Evaluate expression 3x^3 - 2x^2 + 3x - 1
| |----- Print result y
|
|----- Section 3: Evaluation for x = -1
|
|----- Initialize x with -1
|----- Convert x to float
|----- Evaluate expression 3x^3 - 2x^2 + 3x - 1
|----- Print result y
|
End

Include the code you developed

x=0

x = float(x)

y=3*x**3-2*x**2+3*x-1
print("y =", y)

x=1
x = float(x)
y=3*x**3-2*x**2+3*x-1
print("y =", y)

x = -1
x = float(x)
y=3*x**3-2*x**2+3*x-1
print("y =", y)

Include some input/output test data

y = -1.0
y = 3.0
y = -9.0

Reflect on your work:

What errors did you come across?


There's a redundant assignment of the variable x in each section. The variable x is assigned a
float value after its initialization.

How did you overcome these errors?


The unnecessary conversion of x to float is removed, as it does not affect the evaluation of the
given expression.

What new technique (function, operator, or approach) did you use?


There isn't a use of particularly advanced or new techniques. However, the code does
showcase fundamental concepts in Python programming.

Any other comments?


No

Lab Summary and conclusion:


Add a paragraph, summarizing the overall experience and observations in this lab (consider all
parts of the lab as a whole)

In this lab, students gained a basic understanding of Python programming through a


structured series of activities. After covering literals, variables, and arithmetic operations, the
lab moved on to evaluate algebraic expressions, manipulate variables, and convert units.
Essential Python functions such as `print()} and `round()` were emphasized, in addition to
fundamental abilities like manipulating variables and executing mathematical operations.
The lab encouraged hands-on experimentation and research, which resulted in a deeper
understanding of programming ideas. By taking a systematic approach, students gained
practical experience that improved consistency and accuracy in coding methods. All things
considered, the lab provided a comprehensive and insightful introduction to Python
programming concepts, laying the foundation for further study.

You might also like