Question: Language: Python (PyCharm) Hello, I need help with these 10 questions. Language: Python (PyCharm) Hello, I need help with these 10 questions. [1] (homework.py) Create
Language: Python (PyCharm)
Hello, I need help with these 10 questions.

![Python (PyCharm) Hello, I need help with these 10 questions. [1] (homework.py)](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f516c293f5c_17866f516c20c67f.jpg)



Language: Python (PyCharm) Hello, I need help with these 10 questions. [1] (homework.py) Create a folder somewhere on your PC to hold your .py files. But... you must submit each.py file separately. a. Open PyCharm, then create a new PyCharm Project using your assignment folder. Navigate to set the Loca- tion: to this folder and click on Create. b. The Homework -...- PyCharm window should appear, with the Project view showing Homework and other elements on the left-hand side. c. With homework selected, create a new empty Python file hw.py: File->New...->Python File d. Explore the 'modulus' operator: For each expression (expr) in the list below, add a print(expr) to your program and try to predict what the execution output will be before executing the program. When finished, run your program: Run->Run... and select hw.py. Fix any syntax errors until it runs correctly. Your output will appear in a separate Run (console) window. Compare your predictions to what the actual out- put values are. (a) >>>5% 2 (b) >>> 9 %5 (c) >>> 15 % 12 (d) >>> 12 % 15 (e) >>> 6 % 6 (f) >>> 0% 7 (8) >>> 7% 0 [2] (val1.py) Consider the parenthesized expression 2 + (3 - 1) * 10/5* (2 + 3). Write a program which breaks this expression down into a series of assignment statements, each of the form var = el op e2, where var is some variable, where op is one of the arithmetic operators +,-/,* and each of e1 and e2 (expressions) are either (a) an int literal or (b) a variable you assigned a value to in earlier statements. Your final assignment statement should be of the form result = e1 op e2. Note that each of your assignment statements should have only ONE operator and TWO operands on the right- hand side. After this, add the two print statements print(result) and print(2+(3-1)*10/5* (2+3)). Be sure you evaluate the sub-expressions in the correct order when calculating result, so that the output of both is the exactly the same. Note: In this assignment, you must NOT do this for the example expression, but for the expression: 2 + (3 - 1) * 10/5 * (2+3). [3] (val2.py) Do this again for a different expression using different operators - similar to the previous assign- ment item, but for the expression: 1.0+ 2.0 * 5 ** 6** 2%3-6 // 4. Note the use of the two operators ** (exponentiation) and // (integer division). [4] (circle.py) Write code to prompt the user to enter the radius of a circle, read the entered value, then calculate and print out its area. Output both the result and a description of what it represents. [5] (types.py) Python's type(obj) function returns the type of obj. Write a program which prints out as many different Python object types as you can (more than 5), such as: print(type([47])). [6] (lines.py) Write a program draws the picture within the box shown at the right (but don't draw the box.) Each line is of length 200 and separated from the next line by 30 units. The bottom right end of the lowest line is at (0,0) (the turtle's home location), and all lines have a pen width of 3. Be sure to have wn.exitonclick() as the last statement of your program. [7] (range.py) Write a program that uses loops of the form: for num in range...): print (num,end='')# end=" keeps loop output on same line print () # start new line You MUST use a for loop like the above, with range(x,y,z) for some int values of x, y, z to print each of the fol- lowing sequences. 1 2 3 4 5 6 7 8 9 10 1 3 5 79 471 10 9 8 7 6 5 4 3 2 1 10 7 41 15 9 13 17 21 [8] (sumr.py) Write a program that reads integers start and stop from the user, then calculates and prints the sum of the squares of each integer ranging from start to stop, inclusive. "Inclusive" means that both the values start and stop are included. For example, if you enter 2 and 4, your program should print 29 since 2**2+3**2+4**2 == 4+9+16= == 29. Hint: use an accumulator variable. Initialize it before the loop to 0, then add the square of the current loop var- iable to it within the loop body. [9] (mile.py) Write a program that will compute miles per gallon (MPG) mileage for a car. Prompt the user to enter the number of miles driven and the number of gallons used. Print a nice message with the answer. Read each value as float (read as string st then convert using typecast function float(st)). [10] (inter.py) The formula for computing the final amount if one is earning compound interest is given on Wik- ipedia as nt " A= P11+ n Where, . P = principal amount (initial investment) . r= annual nominal interest rate (as a decimal) . n = number of times the interest is compounded per year t = number of years Write a Python program that assigns the principal amount of 10000 to variable P, assign to n the value 12, and assign to r the interest rate of 8% (0.08). Then have the program prompt the user for the number of years, t, that the money will be compounded for. Calculate and print the final amount after t years. The provided starter code for this assignment item does this by using a formula using the exponentiation opera- tor b**n == b*b*...b (n times). Now add statements to this program to compute and print the same result value without using this opera- tor. Use a for-loop to computer = b**n in the following way: r = 1 for counter in range (n): r= r *b You may assume that n is always an int value. Language: Python (PyCharm) Hello, I need help with these 10 questions. [1] (homework.py) Create a folder somewhere on your PC to hold your .py files. But... you must submit each.py file separately. a. Open PyCharm, then create a new PyCharm Project using your assignment folder. Navigate to set the Loca- tion: to this folder and click on Create. b. The Homework -...- PyCharm window should appear, with the Project view showing Homework and other elements on the left-hand side. c. With homework selected, create a new empty Python file hw.py: File->New...->Python File d. Explore the 'modulus' operator: For each expression (expr) in the list below, add a print(expr) to your program and try to predict what the execution output will be before executing the program. When finished, run your program: Run->Run... and select hw.py. Fix any syntax errors until it runs correctly. Your output will appear in a separate Run (console) window. Compare your predictions to what the actual out- put values are. (a) >>>5% 2 (b) >>> 9 %5 (c) >>> 15 % 12 (d) >>> 12 % 15 (e) >>> 6 % 6 (f) >>> 0% 7 (8) >>> 7% 0 [2] (val1.py) Consider the parenthesized expression 2 + (3 - 1) * 10/5* (2 + 3). Write a program which breaks this expression down into a series of assignment statements, each of the form var = el op e2, where var is some variable, where op is one of the arithmetic operators +,-/,* and each of e1 and e2 (expressions) are either (a) an int literal or (b) a variable you assigned a value to in earlier statements. Your final assignment statement should be of the form result = e1 op e2. Note that each of your assignment statements should have only ONE operator and TWO operands on the right- hand side. After this, add the two print statements print(result) and print(2+(3-1)*10/5* (2+3)). Be sure you evaluate the sub-expressions in the correct order when calculating result, so that the output of both is the exactly the same. Note: In this assignment, you must NOT do this for the example expression, but for the expression: 2 + (3 - 1) * 10/5 * (2+3). [3] (val2.py) Do this again for a different expression using different operators - similar to the previous assign- ment item, but for the expression: 1.0+ 2.0 * 5 ** 6** 2%3-6 // 4. Note the use of the two operators ** (exponentiation) and // (integer division). [4] (circle.py) Write code to prompt the user to enter the radius of a circle, read the entered value, then calculate and print out its area. Output both the result and a description of what it represents. [5] (types.py) Python's type(obj) function returns the type of obj. Write a program which prints out as many different Python object types as you can (more than 5), such as: print(type([47])). [6] (lines.py) Write a program draws the picture within the box shown at the right (but don't draw the box.) Each line is of length 200 and separated from the next line by 30 units. The bottom right end of the lowest line is at (0,0) (the turtle's home location), and all lines have a pen width of 3. Be sure to have wn.exitonclick() as the last statement of your program. [7] (range.py) Write a program that uses loops of the form: for num in range...): print (num,end='')# end=" keeps loop output on same line print () # start new line You MUST use a for loop like the above, with range(x,y,z) for some int values of x, y, z to print each of the fol- lowing sequences. 1 2 3 4 5 6 7 8 9 10 1 3 5 79 471 10 9 8 7 6 5 4 3 2 1 10 7 41 15 9 13 17 21 [8] (sumr.py) Write a program that reads integers start and stop from the user, then calculates and prints the sum of the squares of each integer ranging from start to stop, inclusive. "Inclusive" means that both the values start and stop are included. For example, if you enter 2 and 4, your program should print 29 since 2**2+3**2+4**2 == 4+9+16= == 29. Hint: use an accumulator variable. Initialize it before the loop to 0, then add the square of the current loop var- iable to it within the loop body. [9] (mile.py) Write a program that will compute miles per gallon (MPG) mileage for a car. Prompt the user to enter the number of miles driven and the number of gallons used. Print a nice message with the answer. Read each value as float (read as string st then convert using typecast function float(st)). [10] (inter.py) The formula for computing the final amount if one is earning compound interest is given on Wik- ipedia as nt " A= P11+ n Where, . P = principal amount (initial investment) . r= annual nominal interest rate (as a decimal) . n = number of times the interest is compounded per year t = number of years Write a Python program that assigns the principal amount of 10000 to variable P, assign to n the value 12, and assign to r the interest rate of 8% (0.08). Then have the program prompt the user for the number of years, t, that the money will be compounded for. Calculate and print the final amount after t years. The provided starter code for this assignment item does this by using a formula using the exponentiation opera- tor b**n == b*b*...b (n times). Now add statements to this program to compute and print the same result value without using this opera- tor. Use a for-loop to computer = b**n in the following way: r = 1 for counter in range (n): r= r *b You may assume that n is always an int value
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
