Question: if user sent the 1.5 ETH then accepted the 1 ETH, but 0.5 ETH should be refunded to sender. 
I tried like `msg.sender.transfer(0.5)`

and tried like `msg.sender.transfer(500000000000000000)`

but nothing happened. I am not sure about that msg.sender.transfer is a right function.

is it possible do such way in Contracts?

Answer: 
**View** can be used to with a function that does not modify the state but reads state variables.

**Pure** should be used with functions that neither modify state nor read ( access) state variables. They generally perform operations based on input params. 

An example illustrating the same is here:

```
pragma solidity ^0.4.24;

contract ViewVsPure {
  uint public age = 18;

  function addToAge(uint _no) public view returns (uint){
    return age + _no;
  }

  function add(uint _a, uint _b) public pure returns (uint) {
    return _a + _b;
  }
}

```
I think you cant find what you are looking for in the solidity official documentation here: <https://solidity.readthedocs.io/en/v0.4.25/contracts.html?highlight=view%20pure#view-functions>

Hope it helps