Skip to main content

Posts

Showing posts with the label python

How to send and receive discord messages with your bot in 2023.

Hello everyone. Welcome back to the Blog of Chamodh today I will show you how to send and receive discord messages with your bot. Before getting started, I remind you that this is the second episode of the series How to make Discord bot in 2023 and if you haven't read the previous one, please read that first as I explain how to create your bot application and add it to a server there. READ:  https://blogofchamodh.blogspot.com/2023/02/how-to-make-your-own-discord-bot-2023.html We don't gonna use virtual environments, IDEs, or any other utility because we can use Replit for our coding purposes.  Let's Get Started. STEP1: Set up Replit It is really simple. Just go to  https://replit.com/~ and sign up if you have never used its service before and create a new Repl. I don't hope to guide you in this as this is an intermediate tutorial. Make sure to select Python as you create the new Repl because we are going to use Python for our back end. STEP 2: Get your token. To run ou...

How to make a your own Discord bot with Python in 2023. #01

I'm sure that you have heard of discord bots way before reading this article. But have you ever tried to make your own bot with Python? If not, this is the time. Let's get started. Over time tons of discord bot tutorials have been published, but if you follow them they don't help you to build a functional bot because many of the packages used in them are updated and no longer support older syntaxes. Here is the full guide to creating your own Discord Bot in 2023 with Python. STEP 1: Create a Discord account First of all, we have to set up a developer account to create the bot. Actually, you can use your ordinary discord account to access the discord developer portal, but it is highly recommended to create a separate account for development purposes. You can create a new discord account with this link:  https://discord.com/register STEP 2: Create a new Application After creating the discord account, you have to go to the discord developer portal and sign in with your newly-c...

Find the resultant torque of coplanar forces with Python

Hello everyone, today I will show you how to use Python to calculate the resultant torque of coplanar forces. In this article, we will consider forces on a coordinate plane as shown below. To calculate the resultant torque with this Python script, we want to know the magnitude, angle, and coordinates of each force. With this script, we can calculate the resultant torque around any point of the coordinate plane. Let's get started. First of all, we have to install Python and other required software to write our code. After installing Python correctly, open the code editor and create a new file with the .py extension. We don't have to install any other module as the only module we want to use in this project is the math module which comes with Python. You can import the math module with the following line. import math Then we have to create a dictionary to store all the information about forces. You can use a list instead of a dictionary to do that but I prefer using a dictionary...

How to find the index of an element in a Python list.

Hello everyone, welcome back to my blog. I thought to start a series to answer the most googled question on my blogs (this blog and https://talksofchamodh.blogspot.com ) In the first episode I'm gonna show you how to find the index of an element in a list in Python. I'm sure this may have been answered before on other sites I promise you, this tutorial will be the most valuable and authentic answer for this most googled question.   What is a List in Python  A list is a widely used data structure in Python that allows you to store a data sequence. This data type has some unique characteristics. They allow us to manage our memory and do our stuff more efficiently. How to find the index of an element in a list in Python? To find the index of an element in a list, we can use an in-built method called list.index(x). It returns the first item whose value is equal to x. For instance, I have the following list. languages = [ 'python' , 'R' , 'C++' ] And I want ...

Find the nCr value with Python.

What is nCr notation? Hello everyone from this post you will know how to find any nCr value with Python. For those who don't know what nCr is, it is a standard notation in mathematics defined as shown below. This notation is widely used in permutations and combination fields and binomial expansion. Even though we can use the Pascal Triangle to expand binomials it is easier to use the binomial theorem which uses the nCr notation. The n! stands for the product of the numbers from 1 to n which is called the factorial of n. The factorial is defined only for positive integers and 0.  The factorial of 0 equals 1 The factorial of negative integers is not defined. Calculate the nCr Value. When you are provided with two values (n & r) you can use the above equation to calculate their nCr value.  For instance, if you want to find 2C1 you can follow the steps below. With Python..... As shown above you can calculate any nCr value. But when the number increases it becomes harder to cal...

How to Code a Number Guess Game With Python.

How to Code an Advanced Number Guess Game with Python. banner of the game by me:) Hello everyone, I am sure you have played the Number Wordle (Number Guess) Game. Have you ever wanted to create your own number guess game? If yes, this is the time.  It is a game like a wordle to friends who don't know what a number guess game is. The Computer generates a random number; all you have to do is guess that number. If your guess is correct you are rewarded with some points and granted access to higher levels. With Python, you can code this very easily, and let's get started. At this level, we will create a CLI game so that you can understand the basics, and let's move to GUI when you are ready. Prerequisites. All you need is Python and if you have not installed Python yet, visit  https://www.python.org/downloads/ and download the appropriate Python version for you. Getting Started. Create an ASCII banner. First, we want a banner to show the user when they enter the game. It will ...

Create a URL Shortener app with Python and Django. Part-2

Create a URL Shortener app with Python and Django. Part-2 READ PART 1 :  https://blogofchamodh.blogspot.com/2022/07/create-url-shortener-app-with-python.html READ PART 3:  https://blogofchamodh.blogspot.com/2022/08/create-url-shortener-app-with-python.html Photo by  LinkedIn Sales Solutions  on  Unsplash To start the project you have to use the Django-admin  command. This tutorial series is to teach how to create a URL Shortener app and I don't explain the very basics. Please let me know if you want a primary tutorial series in the comment section below. 1. Starting the project. 2. Starting the app To start a Django app we run the python manage.py [APP_NAME]    command. 2. Register the app To tell Django to consider url_shortener as an app for our project we have to edit the settings.py file inside the Shortener Folder. Add a line in the following format to the INSTALLED_APPS list.   [APP_NAME].apps.[APP_CONFIG_NAME]   To fin...