Gas cost depends on two factors. Gas Cost = Gas Limit * Gas Price
Every smart contract in the EVM requires computational work. The amount of computational work is measured in gas. Gas is a fixed value for each computational step. Consider gas as fuel for a car: without fuel a car won’t run. Smart contracts won’t run on Ethereum Virtual Machine without sufficient gas. The more complex a smart contract the more gas it consumes. Every transaction on Ethereum contains a gas limit and a gas price.
Let’s say your operation is to add two numbers. The operation “add” consumes 3 gas. To get the transaction fee we just have to multiply it with the current recommended gas price. Let's assume the recommended gas price is 20 Gweis at the moment.
Now we can calculate the transaction fee or in other words gas cost by multiplying the two factors.
3 gas * 20 Gwei/gas = 60 Gwei = 0.0000006 ETH