Skip to main content

Functions of Python 1: Print, Input and Variables | Python Programming By Akash

 1.   Print function:

Definition: It is a function used to display output on the console screen. By using the simple command print(), you can show text (written inside single or double quotes) or numbers (written directly) inside the round brackets.

For Example,

2.   Comments:

Definition: It is a term used to write notes or explanations inside the code which are completely ignored by the computer. By using the Hash symbol (#), we can write instructions for humans to understand the logic, or temporarily stop a specific line of code from running without deleting it.

For Example,

3.   Input function:

Definition: It is a function used to take data from the user through the console screen. By using the command input(), it accepts the data in the form of a string (simple text). To display a question or message to the user, you can write it inside single or double quotes within the round brackets.

For Example,

4.   Variables:

Definition: It is a name or container used to store data in the computer's memory so you can use it later in your code. It can hold various types of data like strings, numbers, user input, objects, etc. Crucially, this storage is temporary—the variable exists only while the code is running and is destroyed (cleared from memory) once the program stops.

For Example,

Demo Code (Using only simple terms)

5.   F-String (Formatted String):

Definition: It is a smart way to mix variables and text together inside the print function. By simply writing the letter 'f' before the single or double quotes, we can insert variable names directly into the sentence using curly brackets {}, for example: print(f"text {variable}").

For Example,

6.   Newline Character (\n):

Definition: It is a special code used inside a string to break the line. Wherever you place \n in the middle of your text, it forces the output to stop there and immediately start printing the rest on the next new line.

For Example,

Demo Code (Using F-String & Newline Character)



Comments