Posts

Showing posts from September, 2020

Python Booleans

Image
  In computer science, the Boolean data type is a data type that has one of two possible values which is intended to represent the two truth values of logic and Boolean algebra. It is named after George Boole, who first defined an algebraic system of logic in the mid 19th century. The  boolean  data type is either True or False. In  Python ,  boolean  variables are defined by the True and False keywords. >>> a = True >>> type(a) <class ' bool '> >>> b = False >>> type(b) <class ' bool '> The output <class ' bool '> indicates the variable is a  boolean  data type. #Python Boolean #Booleans in Conditionals #Evaluating Values and Variables #False values in Booleans #Class returning False #Boolean Function -Binam Karki

Strings in Python

Image
In the field of Computer Programming, a string is a sequence of characters. In this blog, we will talk about assigning a string to a variable, string concatenation, and different string methods. #String Literals String Literals in Python are either surrounded by single quotation marks or double quotation marks. 'Hello World' is the same as "Hello World" . We can display the string literal with the print() function. #Assigning String to a variable Assigning a string to a variable is done with the variable name followed by an equal sign and a string. #Multiline String We can assign a multiline string to a variable by using three quotes.  eg:  ''' ....... ....... ''' #Strings are Arrays Like other Programming languages, strings in Python are arrays of byte representing Unicode characters. However, Python doesn't have a character data type, a single character is simply a string with a length of 1. Square brackets can be used to access element

Numbers and Casting

Image
In this blog of python series, we will discuss about different types of numbers used in python language, their conversion, random number, and casting. There are three numeric data types in Python. int float complex Variables of numeric types are created when we assign value to them. Int or integer is a whole number, positive or negative, without decimal of unlimited length.  eg: x = 10, x =  -20, x = -34563, x = 9989899 Float or floating-point number is a number, positive or negative containing one or more decimals.    eg: x = 1.0, x = -9.90, x = 23.4532 . Float are also scientific numbers with an 'e' to indicate power of 10.  eg: 35e3 = 35 * 10^3, 23e-2 = 0.23 Complex numbers are written with a "j" as an imaginary part. eg: x = 3+ 5j, x = -3j #Number Conversion Numbers in python can be converted from one type into another type using the following methods: int() float() complex() Our assigned numbers: Conversion from int to float and float to int Conversion f

Data Types in Python

Image
 In any programming language, the concept of data and datatype is very important. In this blog, we will have a brief look at all kinds of data types on Python and we will have a detailed discussion on each topic on upcoming Blogs. Data Types in Python Every value stored in the variable is treated as data whether it is x=5 or y="Nepal". Different kinds of data are used for doing different kinds of things. The following are the list of default data types in python.  Text Type String(str) Numeric Types Integer(int) Float(float) Complex(complex) Sequence Type List Tuple Range Mapping Types Dictionary(dict) Boolean Type bool    We will discuss about each data type in further blogs. #Getting the data types If we are unknown about certain data type, we can get the data type by using type() function. eg: x = 5 print(type(x)) will give result as integer. data = {"name" : "rafel", "a

Python Syntax, Comment and Variable

Image
 In this third Blog of Python series, we will learn about Python Syntax, Python Comment, and Python Variable and a little bit about Scope in Python. 1)Python Syntax Lines of Code that are written in different IDE are known as syntax in Python. Syntax can also be directly run on the command line or python shell.  eg:  >>> print("Hello World")        >>>Hello World #Indentation Spaces at the beginning of the python code line are known as Indentation in Python. In the case of other programming languages,  the indentation is used for the readability of code only but they are very important in python as python use indentation for indicating block of codes. If you skip indentation, python will show an error message. As a programmer, the number of space is up to you, but it should be at least 1. The same number of spaces should be used for same block of codes. eg:   if 5>2:                                                                                         

Getting Started With Python

Image
 Let's get started with Python. For Starting Coding on Python, First of all, you need to download Python from python.org and install it in your system. python.org Homepage Go to python.org You need a Text Editor for writing codes. While downloading Python, it provides us a pre-installed IDLE or Python Shell, which can be used for writing codes. In the beginning, you may use it, but as you increase your horizon in coding, you need IDE for writing codes. Many IDE's are used for Python Programming such as  PyCharm, VS Code, Jupyter Notebook, Sublime Text, and so on.  Pre-Installed IDLE/Python Shell Integrated Development Environment(IDE) Get VS Code from here Some Other IDE's are: Get PyChram form here Get Jupyter Notebook from here Get Sublime Text from here My personal recommendation is VS Code as it is lightweight and user-friendly. We got Python installed on our system and we have code editors too. Now we are ready to start learning Python.  Get Python Official Documentat

Introduction To Python

Image
 In this B log Series, I will be discussing my journey on python beginner course and I will share my experiences along with what I learned.   Python is an interpreted, high-level, and general-purpose programming language, and companies like Facebook, Instagram, Netflix, Quora, and so on use Python as the main language.  Python can be your first language to learn if you are thinking of learning Programming. If you are interested in Coding, you must have heard of languages like Java, C, C++, C#, and so on. These kinds of languages are specific on something such as C++ is mainly used in Game Development and Java is used in android app development. But Python is not limited to a single task. It can be used starting from Web and Game Development to Machine Learning and Artificial Intelligence. Let's take a glance look at where Python is used. 1) GUI Development 2) Data Science 3)Automation Testing 4)Game Development 5)Web Development 6)Image Processing 7)Web Scrapping All these tasks c