Skip to content

Addition is too basic for cool programmers, bringing a new python script for generating a function which effectively increments the value of an integer.

Notifications You must be signed in to change notification settings

anikait1/EffectiveIncrement

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Effective Increment

Addition is too basic for cool programmers, bringing a new python script for generating a function which effectively increments the value of an integer.

Motivation

The script was inspired by a tweet from Pranay Pathole (@PPathole).
Tweet Link

Getting Started

script.py: Contains the actual code to generate the effective increment function.
effective.py: File generated by the script and has the actual function implemention.

Running The Script

Script can be executed either using command line arguments or input from stdin.

Input From Command Line Arguments

1st arg (argv[1]) is the base number to start from.
2nd arg (argv[2]) number of times the base number needs to be incremented.
script.py 10 20

Input From Stdin

In case command line arguments are not given, the script will ask you to enter them. The following message will appear on the terminal.

Either a base number or increment value was not passed
Enter base number: 10
Enter increment value: 20

Example

Running the following command in terminal will generate a file called effective.py, make sure you don't have any other file with this name, chances are it may get overwritten by the script.

python script.py 7 11

effective.py

def effective_increment():
	num = 7

	if num == 7:
		num = 8
	if num == 8:
		num = 9
	if num == 9:
		num = 10
	if num == 10:
		num = 11
	if num == 11:
		num = 12
	if num == 12:
		num = 13
	if num == 13:
		num = 14
	if num == 14:
		num = 15
	if num == 15:
		num = 16
	if num == 16:
		num = 17
	if num == 17:
		num = 18

	return num

main.py

import effective
print(effective.effective_increment())

Why Use Effective Increment

Automation is the future, with this script you can automate the basic task of incrementing a number. Further this script generates more code if the value to be incremented is large. More code means you can charge your client more (looks at COCOMO model). No need to use plus operator just import the effective.py file in your code and directly use the result from the function. Introduces modularity to your code, just like what you were taught in your Software Engineering class in college.

About

Addition is too basic for cool programmers, bringing a new python script for generating a function which effectively increments the value of an integer.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages