PYTHON ( 1 / 1 )

Python example to download webpage  

updated at May 15, 2024   282  
You might have wondered how to download a webpage using Python.It's actually quite simple! With the help of the requests library,you can easily fetch the content of any webpage and use it however you like.Let's walk through a straightforward example togeth...

Python Tutorials for AP Computer Science Principles, Data Projects and High School Internship  

updated at May 10, 2024   1,379  
Python is not just a programming language; it’s a gateway to opportunities in technology.Recognized for its versatility and ease of use,Python has become a staple in data analytics and machine learning,fields that are critical to the tech industry.Many te...

Python Lists  

updated at May 10, 2024   111  
Lists are used to store multiple items in a single variable.Lists are one of 4 built-in data types in Python used to store collections of data,the other 3 are Tuple,Set,and Dictionary,all with different qualities and usage.Lists are created using square br...
Python Lists

Python String Operations  

updated at May 10, 2024   145  
You can return a range of characters by using the slice syntax.Specify the start index and the end index,separated by a colon,to return a part of the string.Slice From the Start.By leaving out the start index,the range will start at the first character:Sli...

Python Variables  

updated at May 10, 2024   716  
Variables are containers for storing data values.Creating Variables.Python has no command for declaring a variable.A variable is created the moment you first assign a value to it.Variables do not need to be declared with any particular type,and can even ch...

Python Data Types  

updated at May 10, 2024   814  
In programming,data type is an important concept.Variables can store data of different types,and different types can do different things.Python has the following data types built-in by default,in these categories:Text Type:str.Numeric Types:int,float,compl...

Python Getting Started  

updated at May 10, 2024   1,146  
Many PCs and Macs will have python already installed.To check if you have python installed on a Windows PC,search in the start bar for Python or run the following on the Command Line (cmd.exe):To check if you have python installed on a Linux or Mac,then on...
Python Getting Started

Python Comments  

updated at May 10, 2024   1,271  
Comments can be used to explain Python code.Comments can be used to make the code more readable.Comments can be used to prevent execution when testing code.Creating a Comment.Comments starts with a #,and Python will ignore them:Comments can be placed at th...

Python Comparison Operators  

updated at May 10, 2024   813  
OperatorDescriptionExample.==,If the values of two operands are equal,then the condition becomes true.(a == b) is not true..!=,If values of two operands are not equal,then condition becomes true.(a != b) is true..If values of two operands are not equal,the...

Python Syntax  

updated at May 10, 2024   912  
Execute Python Syntax.As we learned in the previous page,Python syntax can be executed by writing directly in the Command Line:Or by creating a python file on the server,using the .py file extension,and running it in the Command Line:Python Indentation.Ind...

Python Sets  

updated at May 09, 2024   405  
Sets are used to store multiple items in a single variable.Set is one of 4 built-in data types in Python used to store collections of data,the other 3 are List,Tuple,and Dictionary,all with different qualities and usage.A set is a collection which is unord...

Python Tuples  

updated at May 09, 2024   748  
Tuples are used to store multiple items in a single variable.Tuple is one of 4 built-in data types in Python used to store collections of data,the other 3 are List,Set,and Dictionary,all with different qualities and usage.A tuple is a collection which is o...
Python Tuples

Python Conditions and If statements  

updated at May 09, 2024   558  
Python supports the usual logical conditions from mathematics::Equals: a == b,Not Equals: a != b,Less than: a < b,Less than or equal to: a b,Greater than or equal to: a >= b.These conditions can be used in several ways,most commonly in "if statements" and ...
Python Conditions and If statements

Python Dictionaries  

updated at May 09, 2024   831  
Dictionaries are used to store data values in key:value pairs.A dictionary is a collection which is ordered*,changeable and do not allow duplicates.Dictionaries are written with curly brackets,and have keys and values:Dictionary Items.Dictionary items are ...
Python Dictionaries

Python While Loops/For Loops  

updated at May 09, 2024   676  
The while Loop.With the while loop we can execute a set of statements as long as a condition is true.The while loop requires relevant variables to be ready,in this example we need to define an indexing variable,i,which we set to 1. .The break Statement.Wit...
Python While Loops/For Loops

Python Functions  

updated at May 09, 2024   749  
A function is a block of code which only runs when it is called.You can pass data,known as parameters,into a function.A function can return data as a result.Creating a Function.In Python a function is defined using the def keyword: .Calling a Function.To c...
Python Functions

Python Arrays  

updated at May 09, 2024   407  
Arrays are used to store multiple values in one single variable: Access the Elements of an Array.You refer to an array element by referring to the index number. .The Length of an Array.Use the len() method to return the length of an array (the number of el...

Python Lambda  

updated at May 09, 2024   511  
A lambda function is a small anonymous function.A lambda function can take any number of arguments,but can only have one expression.Syntax.The expression is executed and the result is returned:Lambda functions can take any number of arguments:Summarize arg...
Python Lambda

Python Classes/Objects  

updated at May 09, 2024   619  
Python is object-oriented.In Python,most things are objects with properties and methods.Class is an object constructor or "blueprint" for creating objects.Create a Class.To create a class,use the keyword class: .Create Object.Now we can use the class named...

Python Inheritance  

updated at May 09, 2024   614  
Inheritance allows us to define a class that inherits all the methods and properties from another class.Parent class is the class being inherited from,also called base class.Child class is the class that inherits from another class,also called derived clas...

Python Iterators  

updated at May 09, 2024   734  
An iterator is an object that contains a countable number of values.An iterator is an object that can be iterated upon,meaning that you can traverse through all the values.Technically,in Python,an iterator is an object which implements the iterator protoco...

Python Modules  

updated at May 09, 2024   739  
What is a Module?.Consider a module to be the same as a code library.A file containing a set of functions you want to include in your application.Create a Module.To create a module just save the code you want in a file with the file extension .py:Use a Mod...

Python Polymorphism  

updated at May 09, 2024   762  
The word "polymorphism" means "many forms",and in programming it refers to methods / functions / operators with the same name that can be executed on many objects or classes.Function Polymorphism.An example of a Python function that can be used on differen...

Python Scope  

updated at May 09, 2024   734  
A variable is only available from inside the region it is created.This is called scope.Local Scope.A variable created inside a function belongs to the local scope of that function,and can only be used inside that function.Function Inside Function.As explai...

Mastering Excel Data Manipulation with Python  

updated at Apr 26, 2024   1,139  
Python provides an awesme feature can access Excel spreadsheet file that based on pandas.You can use the pandas library in Python to read an Excel file and store its data into a Python array. Here's a basic example:Replace 'your_excel_file.xlsx' with the p...

Try...Catch Helps Ignoring Data Type Miss-Match Error in Python  

created at Mar 26, 2024   1,396  
In Python, Data Type error is very strong and sensitive, so the application goes down so easily when the type is miss-mathced during the operation. If the data type is a kind of inherited object from a database table, sometimes some of the field could be i...

RegExp example in Python to exclude javascript from HTML code  

created at Mar 22, 2024   1,145  
To exclude JavaScript from HTML code using Python, you can use regular expressions (re module) to remove all tags and their contents. Here's a simple Python function to achieve this:This function exclude_javascript() takes an HTML code string as input and ...

Python code to convert from Lunar to Solar  

created at Mar 22, 2024   1,234  
Converting from the lunar calendar to the solar calendar can be a bit complex due to the differences in the lengths of months and years between the two calendars. Here's a simple Python code using the lunardate library to convert a lunar date to a solar da...

What is Python?  

created at Jun 12, 2023   257  
Python is a genus of constricting snakes in the Pythonidae family native to the tropics and subtropics of the Eastern Hemisphere.In terms of programming language, Python was created by Guido van Rossum, and first released on February 20, 1991. While you ma...
What is Python?

Python Arithmetic Operators  

created at Jun 14, 2023   82  
OperatorDescriptionExample% ModulusDivides left hand operand by right hand operand and returns remainder20 % 10 = 0* MultiplicationMultiplies values on either side of the operator10 * 20 = 200** ExponentPerforms exponential (power) calculation on operators...

Printing string n times  

created at Jun 14, 2023   44  
In Python, you don't need to repeat commands / functions to print a string. You can simply implement it like:

String concatenation by join()  

created at Jun 14, 2023   66  
Write the code for a Python function expand(x) that takes a list of strings, concatenates them, and returns the resulting string repeated three times.Input: ['string1', 'string2']Output: 'string1string2string1string2string1string2' 

Python Introduction  

created at Jun 12, 2023   1,490  
Python is a popular programming language. It was created by Guido van Rossum, and released in 1991.It is used for:web development (server-side), software development, mathematics, system scripting. What can Python do?Python can be used on a server to creat...