Python Forum
Thread Rating:
  • 1 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help
#1
Hello guys , I am super new to scripting and i have got this homework assignment at school and i have no idea what it means , if someone can help me out it would be amazing. This is the Assignment :


Develop a script that generates a list of decimal numbers based on two separate algorithms. The intent is to use the script in order to systematically vary a node attribute in Maya. Name the script “wedgit.py” and save it in a folder called “scripts” that you create under your local home folder. The concept of wedging dates back to earlier days when optical methods were used to match color between film plates that needed to be composited.

The script should consist of a main section and two functions corresponding to each algorithm. The main section parses input arguments using sys.arg and then calls appropriate function.

The script accepts four arguments with the first one being an option string that begins with a dash, ‘-‘, followed by two letters. For this script the options should be ‘-mx’ and ‘-ss’. The three arguments which follow the option string are input to corresponding function and used to generate the list of numbers.

Option ‘-mx’ requires first a minimum value followed by a maximum value and then a scale factor. The range of numbers is calculated by iteratively adding an increment to the minimum value until it exceeds the maximum. The increment is calculated from the difference between maximum and minimum values multiplied by the scale factor.

Option ‘-ss’ generates list of values beginning with start value given as next argument after option string and then iteratively incrementing the value based on a step size given as the next argument. The last argument specifies number of steps to be done iteratively.

Here are examples of running the script using each option respectively:

>python wedgit.py -mx 0.1 0.9 0.2
Wedge values derived from start 0.1, end 0.9, and step factor 0.2
[0.1, 0.26, 0.42, 0.58, 0.74, 0.9]

>python wedgit.py -ss 0.1 0.2 5
Wedge values derived from start 0.1, step size 0.2, and step number 5
[0.1, 0.3, 0.5, 0.7, 0.9]

The script should accommodate situation where no arguments are input. If no arguments are entered, then script should generate lists from both functions using default values. The defaults can be hard-coded within main section but best to use keyword arguments set to default values in the function definition.

Instructions on how to run script either from idle or Windows MS-DOS cmd shell will be given later in a subsequent message.
Reply
#2
You're going to need the sys module to read the arguments passed when the script is run. You could probably use the range built-in to generate the wedge values, but it might be simpler (conceptually) to generate them yourself, starting with an list just containing the start argument and appending to it in a loop.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020