About Lesson
Join the conversation

Book name
Reply

Line magics (prefixed with %):%run: Run the named file as a program.
%load: Load code into the current frontend.
%time: Measure the execution time of a single statement.
%timeit: Time the repeated execution of a statement for better accuracy.Cell magics (prefixed with %%):%%writefile: Write the contents of the cell to a file.
%%html: Render the cell as HTML.
%%latex: Render the cell as LaTeX.
%%bash: Run cell with bash in a subprocess.
%%capture: Capture the output of a cell.General magics:%magic: Display information about all available magic commands.
%lsmagic: List all available magic commands.
%reset: Resets the namespace by removing all names defined by the user.
%who: List all variables of the global scope.
%whos: Like %who, but provides more information about each variable.Shell commands (can be used without %):ls: List files in the current directory.
pwd: Print the current working directory.
cd: Change the current directory.
echo: Print the provided text.
Reply

Baba cant stop my hassi jb ap ny kaha un 3 tariqo ko kaisy use karty hai haha
Reply

done
Reply

Assignment Q. 2:How many ways to format a string in Python?There are five different ways to perform string formatting in Python:
• Formatting with % Operator.
• Formatting with format() string method.
• Formatting with string literals, called f-strings. (Most important and most used command)
• Formatting with String Template Class
• Formatting with center() string method.
Reply

Assignment Q. 1
Enlist the magic commands for Python.Magic Commands
Magic commands let us perform a bunch of tasks from the jupyter notebook itself which otherwise need to be done in the command prompt/shell.
There are two types of magic commands available with Jupyter Notebook:
1. Line Magic Commands: It applies the command to one line of the Jupyter cell as its name suggests.
2. Cell Magic Commands: It applies the command to the whole cell of the notebook and needs to be kept at the beginning of the cell.Line Magic Commands (Starting with "%")
o "%lsmagic" - List All Available Magic Commands
o "%magic" - Print Information About Magic Commands System
o "%quickref" - Cheat-Sheet of Magic Commands
o "%alias_magic" - Give Any Magic Command Alias Name
o "%autocall" - Call Functions without Parenthesis
o "%automagic" - Call Line Magic Commands without "%" Prefix
o "%pwd" - Prints Present Working Directory
o "%cd" - Change Working Directory in Notebook
o "%system" - Execute Unix Shell Commands in Jupyter Notebook
o "%sx" - Execute Unix Shell Commands in Notebook
o "%time" - Measures Execution Time of a Line/Statement in Notebook
o "%timeit" - Measures Execution Time of Line
o "%who" - Prints All Variables Initialized/Declared in Notebook of Specified Data Type
o "%who_ls" - Prints All Variables Initialized/Declared in Notebook of Specified Data Type as "List"
o "%whos" - Prints All Variables in Notebook with Details
o "%load" - Loads Code from Filename in Jupyter Notebook
o "%load_ext" - Load External Module in Jupyter Notebook
o "%unload_ext" - Unload External Module
o "%reload_ext" - Reload Externally Loaded Module
o "%tb" - Print Stack Trace of Last Failure
o "%env" - List, Get and Set Environment Variables in Notebook
o "%set_env" - Set Environment Variables in Notebook
o "%conda" - Execute 'Conda' Commands in Notebook
o "%pip" - Execute Python 'pip' Commands in Notebook
o "%dhist" - Prints History Of Visited Directories in Notebook
o "%history" - Prints History of Commands Executed in Notebook
o "%doctest_mode" - Inform IPython Kernel to Behave Like Normal Python Shell
o "%prun" - Profile Python Code using "profile" Module
o "%matplotlib" - Sets Matplotlib Backend for Plotting
o "%pdef" - Print Signature of Callable
o "%pdoc" - Print Docstring of a Callable
o "%precision" - Sets Precision of Floating Point Numbers
o "%psearch" - Search Namespace using Pattern
o "%psource" - Print Source Code of an Object
o "%pycat" - Shows Content of File with Syntax Highlighted
o "%pylab" - Loads Numpy and Matplotlib in Namespace
o "%recall" - Put History Commands Executed in Next Cell
o "%rerun" - Rerun Previously Executed Cell
o "%reset" - Reset Namespace (Remove All Existing User-defined Names)
o "%reset_selective" - Remove Variables Matching a Pattern
o "%run" - Execute Python Script in Notebook
Cell Magic Commands (Starting with "%%")
o "%%bash" - Execute "bash" Script in Notebook
o "%%script" - Execute Perl, Python, Ruby, and Shell Scripts in Notebook
o "%%sh" - Execute Unix Shell Script in Notebook
o "%%html" - Render Contents of Cell as HTML
o "%%javascript" - Execute Contents of Cell as Javascript
o "%%js" - Execute Contents of Cell as Javascript
o "%%perl" - Execute Contents of Cell as Perl Script/Code
o "%%ruby" - Execute Contents of Cell as Ruby Code
o "%%latex" - Execute Contents of Cell as LaTex (Mathematical Formulas)
o "%%markdown" - Execute Contents of Cell as Markdown
o "%%writefile" - Write Contents of Cell to a File
o "%%time" - Measure Execution Time of Cell Code
o "%%timeit" - Measure Execution Time of Cell Code
o "%%prun" - Profile Cell Python Code
Reply

Great effort 💯azam bhai❤
Reply

Day-19 Assignment 1: List of Magic Commands for Python
1. %run: Run Python script files.
2. %load: Load external code into a cell.
3. %pwd: Print the current working directory.
4. %cd: Change the current working directory.
5. %ls: List files and directories in the current directory.
6. %whos: List all variables in the global scope.
7. %reset: Delete all variables in the global scope.
8. %history: View command history.
9. %env: Access and manipulate environment variables.
10. %debug: Activate the interactive debugger.
11. %pdb: Automatically activate the debugger when an exception is raised.
12. %time: Measure the execution time of a single statement.
13. %timeit: Measure the execution time of a statement or expression with more precision.
14. %prun: Profile code and display detailed profiling information.
15. %memit: Measure memory usage of a single statement.
16. %mprun: Profile code line by line with memory usage.
17. %load_ext: Load a Python extension.
18. %matplotlib: Enable inline plotting with Matplotlib.
19.%store: Pass variables between notebook
Reply

2nd assignemnt ### how many ways are there to format a string?
submitted in discord channel
Reply

done
Reply