Skip to main content

Posts

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
Recent posts

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

Diving into Modules - Math Module

 >Math Module - Overall explanation Source:  freepik Introduction Other than Python built-in functions, there are numerous functions which can be found in some packages which need to be imported when needed which are called modules .  Such a module in python is the math module. Python's standard library provides a module viz. math for math functions that work with all number types except complex numbers. The Math module in Python is enriched with plenty of functions. Note!: To use the math module one must import it first into the Python compiler one has been working with. The syntax to do so is given below: import math FUNCTIONS IN MATH MODULE ceil(): This function returns the closest just above integer when a value has been passed. Syntax: x = math.ceil(2.4) print(x) floor():  This function returns the closest just below integer when a value has been passed. Syntax: y = math.floor(2.4) print(y) fabs():  This function returns the absolute number in floats when a negative

Diving Into Modules - Random Module

  Source:  Cyndie Meyer Random Module: This is an inbuilt module we get in the Python ecosystem and is used for bringing some variability in the program whenever required. This module is full of a ton of functions that are continuously in use in real life. Note! : To use the functions in this module, you have to import this module at least  once. The syntax for this operation is given below. Syntax: import random Some Functions in Random Module random():   This function returns a float value between 0 and 1. Syntax: x = random.random() print(x) randrange():   This function returns a random number between any given range (exclusive of the last number). Syntax: y = random.ranrange(2,7) print(y) randint():  This function returns a random number between any given range (inclusive of the last number). Syntax: z = random.randint(2,7) print(z) More functions will be continued in a later blog post... ©SGPython

Factorial of a Number by a User-Defined Function (PCTS)

 Factorial of a Number There are a number of ways to find the factorial of a number (obviously, it going to a whole number 😆). Out of all of them today, I'm going to show you the user-defined code I created to find the factorial of any whole number. Trust me, it's cool 😎 just give it a try...

For Loops

 The for loop By  polygraphus  on  shutterstock Def: The for loop is also known as the counting loop and is designed to process the items of any sequence, such as a list or a string, one by one. General form of for loop: The general form of the for loop is given below:      for <variable> in <sequence>:          statements to repeat

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 always takes the input in string. Now, let's say we want to make a calculator, so he