Skip to main content

Posts

Type-Casting And Dynamic-Typing

Python is equipped with some of the amazing and easy to use methods which are already built-in keeping the ease of understanding and fun-to-learn. Some of these amazing properties are going to be discussed today in the blog. Type-Casting Typecasting is one of the simple topics of Python which which is very much easy to understand yet is very efficient in the day-to-day lives of Python programmers. Def:  The explicit conversion of an operand to a specific type is called  typecasting. Explicit conversion refers to the type of conversion of datatype into which the user wants to change his or her expression into. Note that these types of conversion are user defined. Typecasting in Python can be explained as follows:                         <datatype> (expression) where <datatype> refers to the datatype into which the user wants to type-cast. Example:  When we use input() function, Python alwa...

YOU CAN GET A TICKET TO MARS FROM NASA

See my ticket for the future flight to the red planet   (Mars) 😍🥳⚡🌟  Okay so firstly, I would like to say that this is not a regular post on Python concepts and codes, but rather on a little talk about my ticket for the future flight to Mars in July 2026. ACTUALLY, I DIDN'T GOT THIS TICKET 🎟️ FOR THE FLIGHT BY GIVING ANY ASTROPHYSICS EXAM OR BY ANY TRAINING AT NASA, BUT I RATHER FILLED A FORM ON the  NASA MARS  website, and got this ticket. So you got it, it is actually for entertainment purpose only. 😅 You can also get the ticket from the link below: https://mars.nasa.gov/participate/send-your-name/future

Rolling Dice Simulator (PCTS)

Python Codes The Series - 2 Photo by Brett Jordan on Unsplash Playing Ludo or Snakes & Ladders and just lost 😰 your dice 🎲; well, no need to worry till I am with you 🙋🏻‍♂️. Just use Python. Many of you might think 🤔 that I am crazy but believe me I am not crazy 😧. We will learn today to use Python for making a rolling dice simulator program.  Here, we are using random module to use the various random functions to make the probability of each outcomes equal. Copy the following code: #importing random module... import random ''' Taking a number between 1 and 10000 using randrange function ''' start = 1 end = 10000 num = random.randrange(start,end+1) #Now choosing the first digit of num from left... num_2 = str(num)[0] num_2 = int(num_2) ''' Finally, choosing the number for the die ''' if num_2 < 6: roll = random.randrange(1,num_2+1) elif num_2 == 6: roll = num_2 else: num_2 = num_2 - 3 roll = ran...

Character Case Swapping (PCTS)

 Python Codes The Series -1 ©Photo by wiki commons Not only in Python but also in the day-to-day life, the letters in English alphabets are characterized into two cases viz. upper case and lower case. Our first program will be a general fun program for the beginners. In this program, we will learn to swap the cases of the letters of English alphabets being entered by the user with the help of a few lines of Python code. For example: If the user enters: " hoLa AmIGo" , the python program would convert this string into " HOlA aMigO" . The Program is noted below: string=input("Enter a string :") length=len(string) s='' for i in range(length): if string[i].islower(): s=s+string[i].upper() elif string[i].isupper(): s=s+string[i].lower() else: s=s+string[i] print(s) FOR QUICK REFERENCE: The len() function gives the length of the string and the the input() function takes input from the user. Hope you like i...

Python Codes The Series (PCTS) - Introduction

 Python Codes The Series (Intro.) Photo by Chris Ried on Unsplash Welcome, to a new series of Python. Within a few upcoming days, we are going to start a pretty new and most useful series of Python named as ' Python Codes The Series ' or ' PCTS ' . As a Computer Science student, I know very well that at a time it really starts to feels quite boring anyways in just the theory classes, so for the entertainment while studying, I have decided to start this series to take a big leap into the real world functioning and see what lies for us in the way. So grab on your PC and get ready for the cool beginning.😜 Going to start the series soon.... 🙃😀 ©SGPython

Opening Python

How to get started with the default CPython distribution Step 1: Download and install the python(3.x) from the provided link:                      https://www.python.org/downloads/ Step 2: Click on windows logo to open the start menu. Step 3: Now from there in Python(3.x) folder, click on Python idle. You can see a window of Python(3.x) idle pops up. Note: There are two modes of working in Python(3.x) idle: 1. Interactive mode: Here, you don’t have to save any python file unnecessarily in order to run it. The user can type the code directly in the idle and the output of the code would be given instantly. 2. Script mode: In script mode, the whole program is written using a number of codes and then saved in an appropriate file which is then run. Here, at last the program generally gets converted into an ‘.exe’ file. Step I: Move your cursor to the top left corner of the idle box, there click on the ...

Basics of Python - 1

 Data types in Python Datatypes are the attributes or  group of specific characters in computer science which tells the compiler or the interpreter about the type of data in which the user want a specific character to be used. Whenever a specific datatype is mentioned by the user, the compiler or the interpreter converts the data to the specific type to be read by the computer. It plays a very vital role in the conversation between the computer and the programmer and without having sufficient types of data it would be really confusing to program any code at all.   The built-in core datatypes provided in Python are: String Numbers List Tuple Dictionary String A string datatype literally holds the actual string data (which may be letters, numbers or special symbols) inside "" or inside '' ,i.e. inside double or single quotation marks. For example: All the following strings are legal and acceptable in Python: "Hello","Holla",'I am great.'...