Skip to main content

Posts

Showing posts with the label CPython

Real-Time Currency Converter (PCTS)

  Currency Converter C urrency Conversion is a basic real time need in today's life, whether it's exchange of currency while tourism or stock market, import and export duties, determine the selling and buying profits of different products around the world. So it can be referred to as one of the key elements in globalization. Use of a Module: Forex Module Install the module into the computer first by running the following command in the Command Prompt: pip install forex-python Copy the following code: from forex_python.converter import CurrencyRates curr = CurrencyRates() print(""" Country with currency codes and currency names Albania ALL lek Algeria DZD dinar Angola AOA kwanza Argentina ARS peso Armenia AMD dram Australia AUD dollar Austria EUR euro Azerbaijan AZN manat Bahrain BHD dinar Barbados BBD dollar Belarus BYN rouble Belgium EUR euro Bermuda BMD dollar Bolivia BOB boliviano Bosnia and Herzegovina BAM konvertibilna marka Botswana BWP pula Br...

SwapCase Type - I (PCTS)

 SwapCase Tutorial  S wapcase is a program to change the cases of the texts (strings), i.e. changing the capital font to small and vice versa. This program can be used to improve the basic python knowledge of python strings and can show how the swapcase() function works internally. It can be done using a lot of algorithms. I'll show you guys 2 tutorials to do the same. In this article, I'll only show the 1st method, then 2nd method will be shown in the next article which would be posted next day. > Method-I Copy the following code: #swapcase (method 1) s = input("Enter your string:") s2 = "" l = len(s) for i in range(l): if s[i].isupper()==True: s2 += s[i].lower() elif s[i].islower()==True: s2 += s[i].upper() else: s2 += s[i] print("Your string after swapping cases:",s2) ©SGPython

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...

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.'...

Our view towards Python (as a programming language)

  Python - The language of the future Introduction When we hear the term programming language, we usually talk about high-level programming language which are those programming language having a lucid (or easy-to-read) syntax and are later converted to low-level language (binary) , which is understandable by the computer.  Programming language has always been an area of interest over the passing years since the very early days of ' Fortran ' (created by John Backus at  IBM ). To this day, dozens of programming language has been created by different 'Computer Scientists' around the world. What is Python? What is Python? Many of you will describe a large scary snake 🐍, which isn't actually wrong 😅. But here we are talking about a programming language. Similarly, Python is also a high-level and interepreted programming language created by  Guido van Rossum in the late 1980s . It was first released in 1991 as a successor to ABC Programming language . It known fo...