you are to write a function and for-loops that outputs the shape like the one below: Introduction to Programming, OUA, Australia

University Open Universities Australia (OUA)
Subject Introduction to Programming

Task 1:

Requirements

  • You must keep the calculation as a single expression on a single line in your final solution.
  • You must not rearrange or simplify the expression in any way.
  • You should parentheses in code so that it is evaluated in the same way as the mathematical expression described above.
  • You must not use any conpcets not covred yet

Example Runs

Run 1

Enter a value for x: 5
Enter a value for y: 3
Enter a value for z: 3
f = -7613.484692283496

Run 2

Enter a value for x: 1
Enter a value for y: 1
Enter a value for z: 1
f = 20.071067811865476

Run 3

Enter a value for x: 100
Enter a value for y: 1
Enter a value for z: 2
f = 47377.17423586197

Program:

x = int(input(“Enter a value for x: “))

y = int(input(“Enter a value for y: “))

z = int(input(“Enter a value for z: “))

f = ((((x – 0.5) * y) ** 0.5 + 1) / 1) + (1 + y * (x ** z)) * ((z+1) ** 0.5 * 4 + 1 – (z ** y) / 1)

print(‘f =  ‘ +str(f))

 Enter a value for x: 100

Enter a value for y: 1

Enter a value for z: 2

f =  59298.935474656995

Task 4:

this task, you are to write a function and for-loops that outputs the shape like the one below. Allow the user to specify how high the shape should be.

Instructions

Your function should take one argument: the height of the shape and then print the shape based on the value of the height

Requirements

To achieve full marks for this task, you must follow the instructions above when writing your solution. Additionally, your solution must adhere to the following requirements:

  • You must implement the for-loops and print inside the function.
  • Appropriate data types must be used for all user inputs.
  • Your solution must not add any more lines of code outside the function implementation.

Example Runs

Run 1

Enter the height: 3
*
***
*****
*^*
^

Run 2

Enter the height: 5
*
***
* # *
*  #  *
*********
*  ^  *
* ^ *
*^*
^

Run 3

Enter the height: 7
*
***
* # *
*  #  *
*   #   *
*    #    *
*************
*    ^    *
*   ^   *
*  ^  *
* ^ *
*^*
^

Run 4

Enter the height: 10
*
***
* # *
*  #  *
*   #   *
*    #    *
*     #     *
*      #      *
*       #       *
*******************
*       ^       *
*      ^      *
*     ^     *
*    ^    *
*   ^   *
*  ^  *
* ^ *
*^*
^

To check for correctness, ensure that your program gives the same outputs as in the examples, as well as trying it with other inputs.

Get Solution of this Assessment. Hire Experts to solve this assignment for you Before Deadline.

Recent Solved Questions