Python Assignment Alternative LUC (Python代写,北美程序代写,美国程序代写,Loyola University Chicago代写)

Write a python program that prints a greeting to the screen.

联系我们
微信: biyeprodaixie 欢迎联系咨询

本次CS代写的主要涉及如下领域: Python代写,北美程序代写,美国程序代写,Loyola University Chicago代写

Python Assignment Alternative #
  1. Read Chapter 1 of the lecture notes posted online:

http://anh.cs.luc.edu/python/hands-on/3.0/handson.pdf

  1. Complete the following programs

Part A: Hello World (hello.py) Write a python program that prints a greeting to the screen.

Part B: Rectangle Perimeter and Area (area.py) Write a python program that prompts the user to enter the length and width of a rectangle and prints out the perimeter and area of that rectangle.

Sample Program Run (User input in bold) What is the length of the rectangle? 12 What is the width of the rectangle? 8 The perimeter of the rectangle is 40 units. The area of the rectangle is 96 square units.

Part C: Table (table.py) Rewrite program 1A using python. In your rewrite, when you prompt users for values, only prompt them to enter one value at a time. Here is a sample of what your program should look like. Feel free to use the posted solution to program 1 to help you write this.

Sample Program Run (User input in bold) What is the length of the room (in feet)? 50 What is the width of the room (in feet)? 30 What is the length of the table (in feet)? 8 What is the width of the table (in feet)? 4 How much space is required between tables (in feet?) 3 How many people does each table set? 10 This arrangement seats 120 people.

Part D: Triangle (triangle.py) In this program you will rewrite the triangle of stars example (http://www.cs.ucf.edu/~dmarino/ucf/cop3223/lectures/stars.c) in python. For your program, define three functions:

  1. printline(n) – this will print out ‘*’ exactly n times
  2. printtri(n) – this will print a triangle with n lines, with 1 star of the first, 2 on the second, etc.
  3. main – this will ask the user to enter n and then print out a triangle with n lines.

In your program, after you define these three functions, just call function main.

Sample Program Run (User input in bold) Enter n 10

**









Part E: Quadratic Formula (quadratic.py) Ask the user to enter a, b and c from the quadratic formula and print out the two roots of the equation. You may assume that a, b and c are entered such that the roots are both real.

Sample Program Run (User input in bold) Enter a 1 Enter b - 5 Enter c 6 Your roots are 3.0 and 2.0.

Part F: Sums (sums.py) Write a program that will calculate the following sums for a positive integer n:

Your program should have a function called sumPow that takes in n and exp, and calculates the sum of the first n positive integers raised to the power exp. Your main function should make three separate calls to the sumPow function. Print out the sum of the square roots to 5 decimal places.

Sample Program Run (User input in bold) Enter n 5 sum of the squares from 1 to n is 55 sum of the cubes from 1 to n is 225 sum of the square roots from 1 to n is 8.

HINTS

If you want to print something without an automatic new line at the end, do the following:

print(‘string here’, end = ‘’)

The last segment that sets end to the empty string ensures that the cursor won’t advance to the next line.

When you read in an input, it gets read into a string. To convert it to an int, use the int function:

n = int(input(“Enter n “))

To raise a value to a power, use the ** operator. For example, we can calculate 1.3 to the 7 power as follows: 1.3**7.

Indenting determines whether or not a statement is inside of a given construct. No braces are used.

If you give the range function 2 parameters, the sequence it will return will start at the first number and end at the last number minus 1. For example, range(2, 8) returns the sequence 2,3,4,5,6,7. If you give the range function 3 parameters, the sequence it will return will start at the first number and count forward by the third number, stopping before it hits the second number. For example, range(10, 22, 3) returns 10, 13, 16, 19.