Your very first program! - Hsanokklis/2023-2024-Tech-journal GitHub Wiki

Functions

Functions are meant to either cause some effect or evaluate a value and return it as the function's result

function arguments

function arguments are whatever goes with in the parentheses, ie in print('Hello World') the argument would be 'Hello World'.

The print() function

The only argument that can be delivered to the print() function is a string

a string is delimited with quotes (""). They says that whatever is written inside of them will be taken as is an NOT executed.


Lab: Become familiar with the Print() function

  • use the print() function to print the line Hello, Python!

image

  • Use the print() function again but print your first name

image

  • You can use the print() function on its own to create a line separation

image

image


the escape and newline characters

\n

  • the backslash \ is otherwise known as an escape
    • This means that when inserted into code, its pausing and including something
  • the n stands for newline

image

The code above prints as:

image

Using multiple arguments

  • One way to combine arguments within a string is with commas

image

Keyword arguments

These are arguments that are added to the end of a string in the print() function and can change the output of the string

image