Applied Programming 1 Lab - Report Format
Applied Programming 1 Lab - Report Format
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
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.
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)”
Output 1
1119.0
Output 2
4+2**4-50*(-2)/0.1+3*(5**2+8)
Output 3
SyntaxError
Reflect on your work:
Part II
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.
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
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)
Part III
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.
Write in words and/or a flow chart what you want each section of your code to do
kilometers = 12.25
miles = 7.38
miles_to_kilometers = miles*1.61
kilometers_to_miles = kilometers/1.61
Part IV
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.
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
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)
y = -1.0
y = 3.0
y = -9.0