Friday 8 May 2020

what is python? | overview about python language

Hello everyone, welcome to my blog post, today we have to start python crash course so first upon required to know the basics of this programming language hence let's start.
INTRODUCTION TO PYTHON:
(Befor the starting the section please read the this post: CLICK HERE)
Python was conceived in the late 1980s as a successor to the ABC language. Python 2.0, released in 2000, introduced features like list comprenstion and a garbage collection system capable of collecting reference cycle. Python 3.0, released in 2008, was a major revision of the language that is not completely backward, and much Python 2 code does not run unmodified on Python 3.
The Python 2 language was officially discontinued in 2020 (first planned for 2015), and "Python 2.7.18 is the last Python 2.7 release and therefore the last Python 2 release. No more security patches or other improvements will be released for it. With Python 2's end of life, only Python 3.5.x and later are supported.
Python is a general purpose and high level programming language. You can use Python for developing desktop GUI applications, websites and web applications. Also, Python, as a high level programming language, allows you to focus on core functionality of the application by taking care of common programming tasks.
Python is an object-oriented programming language created by Guido Rossum in 1989. It is ideally designed for rapid prototyping of complex applications. Python programming is widely used in Artificial Intelligence, Natural Language Generation, Neural Networks and other advanced fields of Computer Science.
(Note: If you want to read more introduction then click on Read more)
                                            BEST OF LUCK!!!!

Evaluate Reverse Polish Notation | Python

Problem Statement:
Evaluate the value of an arithmetic expression in Reverse Polish Notation.

Valid operators are +, -, *, /. Each operand may be an integer or another expression.

Note:

The division between two integers should truncate toward zero.
The given RPN expression is always valid. That means the expression would always evaluate to a result and there won't be any divide by zero operation.
Example 1:

Input: ["2", "1", "+", "3", "*"]
Output: 9
Explanation: ((2 + 1) * 3) = 9
Example 2:

Input: ["4", "13", "5", "/", "+"]
Output: 6
Explanation: (4 + (13 / 5)) = 6
Example 3:

Input: ["10", "6", "9", "3", "+", "-11", "*", "/", "*", "17", "+", "5", "+"]
Output: 22
Explanation:
  ((10 * (6 / ((9 + 3) * -11))) + 17) + 5
= ((10 * (6 / (12 * -11))) + 17) + 5
= ((10 * (6 / -132)) + 17) + 5
= ((10 * 0) + 17) + 5
= (0 + 17) + 5
= 17 + 5
= 22




Code:
class Solution:
    def evalRPN(self, tokens: List[str]) -> int:
        l=[];
        for i in tokens:
            if(i=='+' or i=='-' or i=='*' or i=='/'):
                a=l.pop(-1);
                b=l.pop(-1);
                g=b+i+a;
                w=eval(g);
                e=int(w);
                l.append(str(e));
            else:
                l.append(i);
        return int(l[0]);

Thursday 7 May 2020

if – if else – if else if ladder in C#

C#  IF Statement :

Syntax :

if(condition)
{
//code to be executed
}

Prog : Write a program to test whether a number is even or not





C#  IF-ELSE Statement :

Syntax :

if(Condition)
{
// code to be executed
}else
{
//Code if condition is false
}

Prog : Write a program to test whether a number is even or not




C# IF - ELSE - IF LADDER Statement :

Syntax :

if(Condition1)
{
//code to be executed
}else if (Condition2)
{
//code to be executed
}
else 
{
//Code when all the condition are false
}


Program : Write a program to print Grade of Student as per Marks.



Mathematical functions | Python

For more detail on math module , check the below link: https://docs.python.org/3/library/mat... Relationship between number of digits of a number and it's logarithm: https://math.stackexchange.com/questi... Python for beginners: https://www.youtube.com/watch?v=egq7Z...


Plus One | Python


Python for beginners: https://www.youtube.com/watch?v=egq7Z...

Code:


class Solution:
    def plusOne(self, digits: List[int]) -> List[int]:
        g="";
        for i in digits:
            g+=str(i);
        e=int(g);
        e=e+1;
        g=str(e);
        w=list(g);
        output=[];
        for i in w:
            output.append(int(i));
        return output;


Majority Element | Python

Check the problem statement here:
https://leetcode.com/problems/majorit... Python for beginners: https://www.youtube.com/watch?v=egq7Z...

Code:


class Solution:
    def majorityElement(self, nums: List[int]) -> int:
        nums.sort();
        return nums[len(nums)//2];


Max Consecutive Ones | Python

Check the problem statement here: Max Consecutive Ones https://leetcode.com/problems/max-con... Python for beginners: https://www.youtube.com/watch?v=egq7Z...
Code: class Solution: def findMaxConsecutiveOnes(self, nums: List[int]) -> int: g=""; for i in nums: g=g+str(i); e=g.split('0'); max=0; for i in e: if(max<len(i)): max=len(i); return max;

eval | Python

Explore more about eval here: https://docs.python.org/3/library/fun... https://towardsdatascience.com/python... To convert the string into a numerical value use the function eval(string ) Test the following : a=eval(input()); type(a) Give a as 16 & check whether eval is converting input to a proper numeric datatype or not. Give a as 16.32 & check whether eval is converting a to proper numeric datatype or not. Python for beginners: https://www.youtube.com/watch?v=egq7Z...

The continue Statement | Python

end parameter in print() | Python

Handling Exceptions | Python

You can catch an exception by implementing the try—except construct. This construct is broken into 2 major parts: • try block. The try block indicates the code which is to be monitored for the exceptions listed in the except expressions. • except clause. You can use an optional except clause to indicate what to do when certain classes of exception/error occur (e.g. resolve the problem or generate a warning message). There can be any number of except clauses in sequence checking for different types of error/exceptions. For more detail explanation , check this below link: https://docs.python.org/3/tutorial/er... Python for beginners: https://www.youtube.com/watch?v=egq7Z...

Mathematical Operations on Set | Python

Nth term of GP | Python

Code: a=int(input('Enter the first term')); b=int(input('Enter the second term')); N=int(input('Enter the n value')); # 2 4 8 16 32 r=b/a; s=a*r**(N-1); print(s); Prerequisite: Power of a number | Python | Castor Classes https://www.youtube.com/watch?v=omFAv... Python for beginners: https://www.youtube.com/watch?v=egq7Z...

Is Subsequence | Python

Prerequisite: String in Python | Part 2.3 | Castor Classes https://www.youtube.com/watch?v=65z1V... Check the problem statement here: https://leetcode.com/problems/is-subs... Python for beginners: https://www.youtube.com/watch?v=egq7Z...

Code:


class Solution:
    def isSubsequence(self, s: str, t: str) -> bool:
        g=0;
        for i in s:
            if(i in t):
                rs=t.index(i);
                t=t[rs+1:];
            else:
                g+=1;
        if(g==0):
            return True;
        else:
            return False;


Set | Python

help & tab completion | Python

Topics discussed in this video: a)Getting help in Python & some important methods related to String-- 1).isalpha() 2).isalnum() 3).islower() 4).isupper() b)tab completion in Python Python for beginners: https://www.youtube.com/watch?v=egq7Z...

Tuesday 5 May 2020

what are the difference between LIST , TUPLE and SET in python ?


The tuple, list, set, dictionary are trying to solve the most important problems in programming, called, storage of data and retrieval of stored data in a way that is both easy to use, to code and to read for the programmers.
The big problems are:
- space availability
- insertion
- searching by value or position
- updating
- make the operations faster for big/huge data sets
Tuple:
When you only store data that you aren't changing and don't need to do search by value as you know the position.
List:
When you store data that you changing, inserting if fast and don't need to do search/update by value as you know the position
Set:
When you store data that changes from times to time, but most importantly you need very fast search by value as you don't know position then you use sets.The search is very fast as the set is indexed in memory and fast binary search used. Inserting and deletion is slow.
Dictionary:
When you need fast search, data doesn't change often, few updates and inserts. Is just advanced set where you store a group of key and value and search by the key.

Monday 4 May 2020

Largest Number At Least Twice of Others | Python

Python for beginners: https://www.youtube.com/watch?v=egq7Z...

Code:


class Solution:
    def dominantIndex(self, nums: List[int]) -> int:
        f=max(nums);
        rs=nums.index(f);
        u=[];
        g=0;
        for i in nums:
            if(i!=f):
                u.append(i);
        if(len(u)!=0):
            g=max(u);
        if(f>=2*g):
            return rs;
        else:
            return -1;


Ransom Note | Python

Python for beginners: https://www.youtube.com/watch?v=egq7Z...

Code:


class Solution:
    def canConstruct(self, ransomNote: str, magazine: str) -> bool:
        g=0;
        for i in ransomNote:
            t=ransomNote.count(i);
            s=magazine.count(i);
            if(t>s):
                g+=1;
        if(g==0):
            return True;
        else:
            return False;


Telegram: https://t.me/clcoding_python 
https://www.facebook.com/pirawenpython/ 
https://www.facebook.com/groups/piraw...

Search Insert Position | Python

Python for beginners: https://www.youtube.com/watch?v=egq7Z...

Code:


class Solution:
    def searchInsert(self, nums: List[int], target: int) -> int:
        if(target in nums):
            return nums.index(target);
        else:
            if(target<min(nums)):
                return 0;
            elif(target>max(nums)):
                return len(nums);
            else:
                g=0;
                m=0;
                while(g<len(nums)):
                    if(nums[g]>target):
                        m=g;
                        break;
                    g=g+1;
                return m;


Intersection of Two Arrays | Python

Check the problem statement here: The intersection of Two Arrays: https://leetcode.com/problems/interse... Python for beginners: https://www.youtube.com/watch?v=egq7Z...

Code:


class Solution:
    def intersection(self, nums1: List[int], nums2: List[int]) -> List[int]:
        output=[];
        for i in nums1:
            if(i in nums2 and i not in output):
                output.append(i);
        return output;


Telegram: https://t.me/clcoding_python 
https://www.facebook.com/pirawenpython/ 
https://www.facebook.com/groups/piraw...

Popular Posts

Categories

AI (27) Android (24) AngularJS (1) Assembly Language (2) aws (17) Azure (7) BI (10) book (4) Books (117) C (77) C# (12) C++ (82) Course (62) Coursera (179) coursewra (1) Cybersecurity (22) data management (11) Data Science (95) Data Strucures (6) Deep Learning (9) Django (6) Downloads (3) edx (2) Engineering (14) Excel (13) Factorial (1) Finance (6) flutter (1) FPL (17) Google (19) Hadoop (3) HTML&CSS (46) IBM (25) IoT (1) IS (25) Java (92) Leet Code (4) Machine Learning (44) Meta (18) MICHIGAN (5) microsoft (3) Pandas (3) PHP (20) Projects (29) Python (752) Python Coding Challenge (226) Questions (2) R (70) React (6) Scripting (1) security (3) Selenium Webdriver (2) Software (17) SQL (40) UX Research (1) web application (8)

Followers

Person climbing a staircase. Learn Data Science from Scratch: online program with 21 courses