Different Assignments Needed On 3 Different Files
3 Different Assignements Needed On 3 Different Files1one Of The Mos
1. One of the most common data types in all programming languages is Float, which represents decimal values. Programming declares variables and specifies the data types of these variables at the beginning of a program. However, depending on the order of operations, the output of an operation involving floating numbers might not necessarily be a floating number.
Input the following in JES or Python IDLE to see the output:
print 1.0 / 3
print 10 + 3 * 7
print (10 + 3) * 7
Zip your Python .py file and submit the .zip file so the code can be validated. Write a ½ page on why each of your three inputs resulted in its particular output.
2. String Concatenation in Python
In Python, there are a few different ways of concatenating strings as explained in Chapter 3, "Creating and Modifying Text," of "Introduction to Computing and Programming in Python." Input the following in JES to see how strings are concatenated in the output:
print "Hi" + "there"
print "Hi" + 10
print "Hi" * 10
Zip your Python .py file and submit the .zip file so the code can be validated. Write a ½ page on why each of your three inputs resulted in its particular output.
3. Combining Variables, Conditionals, and Output Logic
This programming assignment will integrate everything learned this week. You will:
- Create variables and assign them values.
- Add the variables.
- Use a conditional statement to determine an appropriate string to print.
Write a program in JES that performs the following steps:
- Create two variables: Num_1 and Num_2.
- Assign the value 50 to Num_1 and 25 to Num_2.
- Create a third variable, Total, that adds Num_1 and Num_2.
- Determine if Total is greater than 100, between 50 and 99, or less than 50 using if, elif, or else statements:
- If Total is greater than 100, print a string showing Total combined with "is too high".
- If Total is less than 50, print Total with "is too low".
- If Total is between 50 and 99, print Total with "is in the correct range".
Iteration 1: Run your program with initial values (50 and 25). The output should be "75 is in the correct range". Debug if necessary.
Iteration 2: Change the value of Num_1 to a number that makes Total > 100. Run and demonstrate the output.
Iteration 3: Change Num_1 to a number that makes Total
Zip your Python .py file and submit the .zip file for validation at each step.
Paper For Above instruction
The above instructions encompass three distinct programming exercises designed to solidify fundamental concepts in Python programming, including data types, string manipulation, and control structures. In the first task, the focus is on understanding the behavior of floating-point division and the effects of order of operations on the output. The second task emphasizes string concatenation techniques and the importance of data types when performing string operations. Finally, the third task involves creating variables, performing arithmetic operations, and applying conditional logic to output contextually relevant messages based on the sum of two numbers.
In the first task, using print statements to perform different operations showcases how Python handles floating-point division and arithmetic. For example, executing "print 1.0 / 3" results in a decimal approximation, demonstrating Python’s floating-point division capabilities. The order of operations plays a crucial role, as seen with "print 10 + 3 7" and "(10 + 3) 7," illustrating how multiplication precedence affects the calculations. This task emphasizes how the underlying mathematical principles and operator precedence influence program output, which is essential for debugging and ensuring accurate calculations.
The second task explores string concatenation, an essential skill in text processing. Using the "+" operator to combine strings ("Hi" + "there") results in a single string "Hithere," while attempting to concatenate a string with an integer ("Hi" + 10) raises a type error unless the integer is converted to a string using str(10). The "" operator when applied to a string and an integer (e.g., "Hi" 10) repeats the string multiple times, producing "HiHiHi...". These examples underscore the importance of understanding data types and the specific operations supported by strings in Python, which impact how text is manipulated and displayed in programs.
The third task synthesizes variable creation, arithmetic, and control flow to produce dynamic output. Assigning values to Num_1 and Num_2, then computing their sum in Total, demonstrates how variables store data and how arithmetic operations can be performed on them. The subsequent conditional logic involves checking if Total exceeds certain thresholds and printing appropriate messages. By modifying Num_1 in subsequent iterations, students observe how changing input data affects program behavior and output. Debugging ensures that the program outputs "75 is in the correct range" initially, then displays "Total is too high" or "Total is too low" based on the new values. This exercise develops understanding of program flow, decision-making, and how to communicate results effectively via print statements.
Overall, these exercises are critical for building a solid foundation in programming logic, data type management, and debugging strategies. Mastery of these concepts enables students to develop more complex applications and understand the intricate details of Python’s operation and behavior, which are fundamental skills for any aspiring programmer.
References
- Downey, A. (2015). Think Python: How to Think Like a Computer Scientist. O'Reilly Media.
- Swaroop, C. H. (2017). A Byte of Python. https://python.swaroopch.com/
- Guido van Rossum & Fred L. Drake, Jr. (2011). The Python Language Reference. Python Software Foundation.
- Lutz, M. (2013). Learning Python (5th Edition). O'Reilly Media.
- Beazley, D. (2013). Python Essential Reference. Addison-Wesley.
- Millman, K. N., & Grinstein, D. (2014). Python for Data Analysis. O'Reilly Media.
- Chun, W. (2018). Core Python Programming. Prentice Hall.
- Hunt, A., & Thomas, D. (1999). The Pragmatic Programmer. Addison-Wesley.
- Fitzgerald, U. (2019). Foundations of Python Programming. Packt Publishing.
- VanderPlas, J. (2016). Python Data Science Handbook. O'Reilly Media.