logo
down
shadow

how to write a program


how to write a program

By : Willem
Date : November 22 2020, 10:40 AM
this will help I'm trying to write a program that would output of an item which is worth 10000 over a period of 15 years using this formula:
code :
def main():
    print("Sum-of-the-Years'-Digits Method")

    years = 15
    sum_of_years = years * (years + 1) // 2    # = sum(1..years)
    initial_value = 10000000

    value = initial_value
    for year in range(years):
        depr = (years - year) / sum_of_years * initial_value
        value -= depr
        print("End of year {}: depreciation = {:0.2f}, new value = {:0.2f}".format(year + 1, depr, value))

if __name__=="__main__":
    main()
Sum-of-the-Years'-Digits Method
End of year 1: depreciation = 1250000.00, new value = 8750000.00
End of year 2: depreciation = 1166666.67, new value = 7583333.33
End of year 3: depreciation = 1083333.33, new value = 6500000.00
End of year 4: depreciation = 1000000.00, new value = 5500000.00
End of year 5: depreciation = 916666.67, new value = 4583333.33
End of year 6: depreciation = 833333.33, new value = 3750000.00
End of year 7: depreciation = 750000.00, new value = 3000000.00
End of year 8: depreciation = 666666.67, new value = 2333333.33
End of year 9: depreciation = 583333.33, new value = 1750000.00
End of year 10: depreciation = 500000.00, new value = 1250000.00
End of year 11: depreciation = 416666.67, new value = 833333.33
End of year 12: depreciation = 333333.33, new value = 500000.00
End of year 13: depreciation = 250000.00, new value = 250000.00
End of year 14: depreciation = 166666.67, new value = 83333.33
End of year 15: depreciation = 83333.33, new value = 0.00


Share : facebook icon twitter icon
Write a program to exploit the stack overflow vulnerability of the program and obtain a shell on Linux

Write a program to exploit the stack overflow vulnerability of the program and obtain a shell on Linux


By : Aasif Tamboli
Date : March 29 2020, 07:55 AM
hop of those help? The key to your ability to exploit this code, is the following two lines:
code :
char buf[12];
strcpy(buf, argv1);
How do I write a program to produce properly quoted command line arguments for another program?

How do I write a program to produce properly quoted command line arguments for another program?


By : twolfmai
Date : March 29 2020, 07:55 AM
wish of those help I need to write a program whose output is part of a command line for another program. e.g. , Something like this may work.
code :
# Make helper output an array assignment
% helper
options=( --arg1='foo bar' --arg2='another string' )

# Use eval to actually define the array using the output of helper
% eval "$(helper)"
% echo "${options[0]}"
--arg1='foo bar'

# Call program using options instead of helper directly
% program "${options[@]}"
% eval "program $(helper)"
Java Program - Write a program that calculates the area of a circle using a method called circleArea

Java Program - Write a program that calculates the area of a circle using a method called circleArea


By : user2523922
Date : March 29 2020, 07:55 AM
With these it helps The parameter of areaCalc() should be of type double, but it is int. When you pass a double, it must be converted to an int, but that will cause a loss of precision and the language requires you to make an explicit cast if you attempt that.
If you code your method like this:
code :
public static double areaCalc(double n1) { ... }
Java Program Unable to Write Sqlite DB inside Windows Program Files

Java Program Unable to Write Sqlite DB inside Windows Program Files


By : Trombini
Date : March 29 2020, 07:55 AM
I wish did fix the issue. That's only the security features from Windows, nothing wrong with your Program. Inno setup and your program should store the sqlite-db in e.g. %AppData% and not under c:/Program Files/
I cant figure out quite how to write this program. I want to make the program ask the user for speed and time and use a

I cant figure out quite how to write this program. I want to make the program ask the user for speed and time and use a


By : user3463149
Date : March 29 2020, 07:55 AM
may help you . You are missing a closing parenthesis to terminate your for loop. In the future, you should indent your code to make catching errors like this easier. Although I'm not sure what exactly the purpose of the for loop is in your code, since you are just assigning the same value to mph 5 times.
code :
function showAndCalculateDistance(speed, time) {

    for (var i=0; i<5; i++){

        var mph = vehicleSpeed* timeTraveled;

    }

    return mph

} // <-- you did not put this.

var vehicleSpeed = parseInt(prompt('How fast is the vehicle traveling (in miles per hour)? '));
var timeTraveled = parseFloat(prompt('How long has this vehicle traveled (in hours)? '));
var totalDistanceTraveled = showAndCalculateDistance(vehicleSpeed,timeTraveled);
alert('In ' + timeTraveled + ' hours, a vehicle traveling at ' + vehicleSpeed + ' miles/hour will have traveled ' + totalDistanceTraveled + ' miles.');
Related Posts Related Posts :
  • Read data with NAs into python and calculate mean row-wise
  • How to print telnet response line by line?
  • Pylint: Avoid checking INSIDE DOCSTRINGS (global directive / rcfile)
  • Sending MIDI messages using Python (on Ubuntu)
  • Generate Dictionary in Python at run time
  • code is cluttered by try-except in Python
  • Python class inheritance - spooky action
  • Why is a Python multiprocessing daemon process not printing to standard output?
  • How to feed numeric data into a classifier?
  • How to unambiguously identify a Model as a lowercase string in Django
  • How to get only one specific line from subprocess output
  • Python network communication with encryption and password protection
  • with urllib urlopen read function but get none
  • django could not find database in ubuntu
  • How to replace a character in a string with a non ascii character in python?
  • Self learning data evaluation in Python
  • Django: UnicodeDecodeError while trying to read template 500.html
  • how can you Import an os variable into PYTHON and have it update?
  • Browse Folders to open a file in python
  • sql select group by a having count(1) > 1 equivalent in python pandas?
  • Why Insert command when button clicked OpenERP
  • Pandas dataframe from nested dictionary to melted data frame
  • Which is more efficient in Python: list.index() or dict.get()
  • Xor bits in python
  • A simple python confusion about format string
  • Finding index of a list containing an item, also in a list
  • How to test Domain is it 'www' domain or subdomain or name server domain or mail domain in python?
  • Keydown event for Pygame
  • Lazy loading csv with pandas
  • Use webdriver,python,beautifulsoup to retrieve dynamic website
  • Scrapy is Visiting same Url despite dont_filter=False
  • How to add support for SNI in python 2.7
  • Pandas: np.where with multiple conditions on dataframes
  • How to get meaningful words by splitting a continuous string?
  • TypeError: 'numpy.ndarray' object is not callable while extracting index and elements are stored in different array in p
  • Python: comparing list to a string
  • Is there any way to write '\r' into a file on linux with python?
  • matplotlib retrieve color from plt.plot command
  • Scrapy JSON export issues
  • beautifulsoup to retrieve the date
  • Django Rest Framework 3.0: Saving Nested, Many-To-One Relationship
  • Lost connection to MySQL server during Python connection
  • uploadede file path django
  • How to reduce a data with the longest string under pandas framework?
  • Single line for-loop to build a dictionary?
  • How to read in lines until a certain line?
  • Beautifulsoup to retrieve the href list
  • Python - Vincenty's inverse formula not converging (Finding distance between points on Earth)
  • Saving django model instance into another model
  • Same URL request fails with python->urllib but not with curl
  • Python dictionary: set value as the key string
  • With setuptools, when does namespace packages __init__.py files disappears?
  • Paraview: NameError: name 'inputs' is not defined
  • Too many values to unpack during template rendering
  • A different type of iterative function
  • Test if value exists in several lists
  • Go and Python HMAC libraries give different results
  • Python Nested Loop Working Weirdly
  • Why is this not assigning the correct value?
  • 'numpy.ndarray' object is not callable
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org