Grok Tips

From Free Knowledge Base- The DUCK Project
Jump to navigation Jump to search

programming source code markdown

If you want to distinguish source code from regular text in your instructions, feel free to use Markdown syntax. Specifically, you can use triple backticks (```) to create a code block for your source code, or single backticks (`) for inline code. Grok will interpret it accordingly and treat the code portions as distinct from regular instructions.

Example:

```python
def greet(name):
    return f"Hello, {name}!"
print(greet("Alice"))

Another Example:

I need you to find the bug in this PHP code.

```php
function calculateDiscount($price, $discount) {
    $result = $price - ($price * $discount / 100);
    echo "The discounted price is: " $result;
    return $result
}

$finalPrice = calculateDiscount(100, 20);
```