Posts

How to automate boring stuff with python chapter 2: Practice Questions

Image
Practice Questions   1.  What are the two values of the Boolean data type? How do you write  them?  2.  What are the three Boolean operators?  3.  Write out the truth tables of each Boolean operator (that is, every possible combination of Boolean values for the operator and what they  evaluate  to).  4.  What do the following expressions evaluate to?  5.  What are the six comparison operators?  6.  What is the difference between the equal to operator and the assignment  operator?  7. Explain what a condition is and where you would use one.  8.  Identify the three blocks in this code: 9.  Write code that prints  Hello  if  1  is stored in  spam, prints  Howdy  if  2  is stored in  spam, and prints  Greetings!  if anything else is stored in  spam.  10.  What can you press if your program is st...

Python FAQs

What is python interpreter? Python interpreter is basically a program that executed python codes. We can write python codes in a file and open that file in python interpreter to execute the code. What is interactive shell? Interactive shell a shell like command line where we can write short programs and get output on the go there only. What is difference between IDE and code editor? Code is simply a software in which we can write our code while IDE(intergrated development environment) is a software to write a code with some extra benefits like autocompletion, debugging and testing. Examples of some famous code editors are VS code, sublime text and Atom while most famous IDE for python is pycharm. What is an expression. Expression is a piece of code that produces a value. What are primitive data types in python. The three primitive data types in python are numbers, Boolean and strings. How many types of numbers are in python. There are 3 types of numbers in python: integers, floats and ...

File Permission Systems in Computer

Image
File permissions system : eg drwxr-xr-x this is a 9 or 10 letter string (if 10 letters then the first one will tell either it is file or directory, d means directory and dash(-) for file) rest 9 letters can be divided into 3x3, in which the first three permission are for owner(U), the mid three letters are for group(G) and the last three letters are for public/others(O). There the first letter out each three are read(r), the second write(w) and the third execute(x). If any of these permission isn't give to any user then that place is filled by dash(-) other the letter is present. # there are two kinds of representation of permission systems : numeric and symbolic . The above was explanation of symbolic. # the numeric permission representation is from 000 to 777. The first character is for owner(who created the file), the second is for group and the third for public/others. The values of different permission are as: read=4, write=2, execute=1. If some permissions aren...

Operators in python

Operator are symbols that perform some actions or operations. There are 7 types of operations in python: 1.  Arithmetic operators 2. Comparison or relational operators 3. Logical operators 4. Assignment operators 5. Membership operators 6. Identity operators 7. Bitwise operators Arithmetic operators are used to perform basic arithmetic operations. These are of 7 types in python: I. Addition (+) II. Subtraction (-) III. Multiplication (*) IV. Division (/) V. Exponentiation (**) VI. Modulus (%) VII. Floor division (//) Comparison operators are used to compare the two values on both side of the operators to produce logical/Boolean value True or False. There are 6 types of comparison operators in python: I. Less than (<) II. Greater than (>) III. Less than or equal to (<=) IV. Greater than or equal to (>=) V. Equal to (==) VI. Not equal to (!=) Logical operators are used to combine conditional statements and the combined expression is called logical expression which always ...

Data Types in Python

The data types can be classified into two categories: A. Python built-in data types B. User defined data types. Built-in data types in python can be classified be various categories: Text Type: str Numeric Types: int , float , complex Sequence Types: list , tuple , range Mapping Type: dict Set Types: set , frozenset Boolean Type: bool Binary Types: bytes , bytearray , memoryview The major data types out of these are string, numeric, list, tuple, dictionary, set and boolean. We can get the data type of any object by using the type()  function.

Keywords in Python 3.8.2

Image
Reserved words (also called keywords) are defined with predefined meaning and syntax in the language. These keywords have to be used to develop programming instructions. Reserved words can’t be used as identifiers for other programming elements like name of variable, function etc. Following is the list of 35 reserved keywords in Python 3.8.2 We can get the list of all keywords in any version of python using the module keyword as follows. import keyword keyword.kwlist ['False', 'None', 'True', 'and', 'as', 'assert', 'async', 'await', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', ...