Saturday 2 May 2020

Brian Kernighan’s Algorithm | Python

Code: class Solution: def countBits(self, num: int) -> List[int]: bum=[]; i=0; while(i<=num): bum.append(i); i=i+1; output=[]; for i in bum: count=0; while(i>0): i=i&i-1; count+=1;#count=count+1; output.append(count); return output;

Number of 1 Bits https://leetcode.com/problems/number-... Counting Bits https://leetcode.com/problems/countin... Code is given in the comment section. Python for beginners: https://www.youtube.com/watch?v=egq7Z...

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

Last Stone Weight | Python

Code: class Solution: def lastStoneWeight(self, stones: List[int]) -> int: while(len(stones)>1): heaviest=max(stones); stones.remove(heaviest); heavier=max(stones); stones.remove(heavier); if(heaviest!=heavier): stones.append(heaviest-heavier); if(len(stones)==0): return 0; else: return stones[0];

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

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

Move Zeroes | Python

Code: class Solution: def moveZeroes(self, nums: List[int]) -> None: g=nums.count(0); i=0; while(i<g): nums.remove(0); nums.append(0); i=i+1;

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

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


Counting Elements | Python

Code :

class Solution: def countElements(self, arr: List[int]) -> int: output=0; for i in arr: if(i+1 in arr): output+=1; return output;
Python for beginners: https://www.youtube.com/watch?v=egq7Z..

Telegram: https://t.me/clcoding_python


Program to find whether a no is power of two or not | Python

Prerequisite: Data Type Conversion | Python | Castor Classes https://www.youtube.com/watch?v=z8yw6... Turn off the rightmost set bit | Python | Castor Classes https://www.youtube.com/watch?v=ol4VW... Relationship between binary representation of n & n-1 | Python | Castor Classes https://www.youtube.com/watch?v=iTxc9... Python for beginners: https://www.youtube.com/watch?v=egq7Z..

Telegram: https://t.me/clcoding_python

Escape Sequence in Python

Escape Sequence - 

Escape sequences are control character used to move the cursor and print characters such as ',".\ and so on.


















Friday 1 May 2020

Python Input() Function

Input( )

Python provides us the facility to take input from user using Input( ) function. This function prompts the user to input a value.

For example :

Name = input("Enter Your Name");
print(Name);

Output will be the name as entered by the user.

Let us take the example again:

name = input("Enter Your Name:");
print("Welcome Mr.",name);

Here suppose the user enter the name as "xyz Kumar" so the variable name will contain xyz Kumar. In such case the output of the program will be:

Output      Welcome Mr. xyz Kumar


 Please note that the input( ) accepts the input only in string format. so, if any mathematical calculation is to be performed, we need to convert the input to integer format. for converting the input to integer format Python provide us a function called :

Program without using int( ) function :

a = input ("Enter 1st Number:");
b =  input("Enter 2nd Number:");
c = a+b;
print("Addition =",c);

In this case if the value of a & b as given by user is 5 & 6 respectively then the output will be 56. As 5 & 6 will be treated as string and not integer.

Program using int( ) function

a = int(input("Enter 1st Number:"));
b = int(input("Enter 2nd Number:"));
c=a+b;
print("Addition=",c);

 In this case if the value of a & b as given by user is 5 & 6 then output will be 11 as we have converted the input from string to integer format.



Thursday 30 April 2020

Turn off the rightmost set bit | Python

Question: Write a program that unsets the rightmost set bit of an integer. Input: 12 Output: 8 Input: 7 Output: 6 Simple code: n=int(input()); print(n & (n-1)) Prerequisite: Data Type Conversion | Python | Castor Classes https://www.youtube.com/watch?v=z8yw6... Relationship between binary representation of n & n-1 | Python | Castor Classes https://www.youtube.com/watch?v=iTxc9... Python for beginners: https://www.youtube.com/watch?v=egq7Z..

Join: t.me/clcoding_python

Relationship between binary representation of n & n-1 | Python

Let's learn Python from basics.

Prerequisite:
Data Type Conversion | Python | Castor Classes
https://www.youtube.com/watch?v=z8yw67K8rC0 Python for beginners:
https://www.youtube.com/watch?v=nAWv9rGwGMQ&list=PLNhFkFk6qEgIq3lcbmxWIBFjEcq4lwRyk

Join: t.me/clcoding_python


Like us: https://www.facebook.com/pirawenpython/

Checking a number is Odd or Even using Bitwise Operators | Python

Prerequisite:
Bitwise Operation in Python | Castor Classes
https://www.youtube.com/watch?v=mqkBM9Nwy3k Python for beginners:
https://www.youtube.com/watch?v=nAWv9rGwGMQ&list=PLNhFkFk6qEgIq3lcbmxWIBFjEcq4lwRyk

Join: t.me/clcoding_python

#Code
e=10;
e%2==0

True

f=11;
f%2==0

False 

Like us: https://www.facebook.com/pirawenpython/

Tuple in Python | Part 2

Topics discussed in this video:
1)Accessing Elements of a Tuple
2)Creating New Tuples from Existing Tuples
3)Iterating Over Tuples
4)length of a Tuple
5)count how many times a specified value appears in a Tuple
6)find out the (first) index of a value in a Tuple
7)Checking if an Element Exists
8)Nested Tuples
9)Can we add or remove elements from a Tuple?

Prerequisite: Tuple in Python | Castor Classes https://www.youtube.com/watch?v=QJcs3... Python for beginners: https://www.youtube.com/watch?v=egq7Z...

Nested List & Matrix | List in Python | Part 7

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

#Code to take Matrix input from user in Python
row=int(input("Enter the number of row:"));
column=int(input("Enter the number of columns:"));
l=[];
rs=[];
i=0;
j=0;
while i<row:
    while j<column:
        u=int(input());
        rs.append(u);
        j=j+1;
    l.append(rs);
    rs=[];
    j=0;
    i=i+1;
l



Wednesday 29 April 2020

Converting an Input String into a Floating Point Number | Python

List Traversal using while loop & break statement | Python

Code: mylist=[]; l=int(input()); i=0; while(i<l): m=int(input()); mylist.append(m); i=i+1; i=0; g=0; while(i<=l-2): es=mylist[i]; ms=mylist[i+1]; if(es==ms and ms==4): g=g+1; break; i=i+1; if(g==0): print(False); else: print(True);


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

Int to String ,Float to String ,String to Int & String to Float conversion | Python

Topics covered: 1)Integer to String conversion 2)Float to String conversion 3)String to Integer conversion 4)String to Float conversion 5)Different way to concatenate string Python for beginners: https://www.youtube.com/watch?v=egq7Z...


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

Stacks and Queues using List | Data Structures | Python

Topics discussed: 1)Stack using List 2)Queue using List Prerequisite: List in Python | Part 1 | Castor Classes https://www.youtube.com/watch?v=P2ogQ... List in Python | Part 2 | Castor Classes https://www.youtube.com/watch?v=vNxxQ... Python for beginners: https://www.youtube.com/watch?v=egq7Z...

Tuesday 28 April 2020

Tuple in Python

Topics covered: 1)Tuple 2)Packing 3)Unpacking 4)Swap two variables using Packing & Unpacking concept 5)Tuple with List Python for beginners: https://www.youtube.com/watch?v=egq7Z...



Web ๐ŸŒhttp://www.clcoding.com/ Telegram: https://t.me/clcoding_python https://www.facebook.com/pirawenpython/ https://www.facebook.com/groups/piraw..

Subtract the Product and Sum of Digits of an Integer | Python

Prerequisite:
Sum of Digits of a number | Python | Castor Classes
https://www.youtube.com/watch?v=IBK1-... Python for beginners:
https://www.youtube.com/watch?v=egq7Z...


Maximum 69 Number | Python

Check the problem statement here:
https://leetcode.com/problems/maximum... Prerequisite: List in Python | Part 6 | Castor Classes https://www.youtube.com/watch?v=kIpXn...

Factorials of large numbers | Python

In Python, value of an integer is not restricted by the number of bits and can expand to the limit of the available memory. Thus we never need any special arrangement for storing large numbers. Prerequisite: Loops in Python | Castor Classes https://www.youtube.com/watch?v=SZmbd


Monday 27 April 2020

Advanced Guide to Python 3 Programming for Undergraduate Topics in Computer Science pdf

Advanced Guide to Python 3 Programming delves deeply into a host of subjects that you need to understand if you are to develop sophisticated real-world programs. Each topic is preceded by an introduction followed by more advanced topics, along with numerous examples, that take you to an advanced level.

There are nine different sections within the book covering Computer Graphics
(including GUIs), Games, Testing, File Input and Output, Databases Access, Logging, Concurrency and Parallelism, Reactive programming, and Networking. Each section is self-contained and can either be read on its own or as part of the book as a whole.

This book is aimed at the those who have learnt the basics of the Python 3 language
but want to delve deeper into Python’s eco system of additional libraries and modules,
to explore concurrency and parallelism, to create impressive looking graphical interfaces, to work with databases and files and to provide professional logging facilities.
Buy: Advanced Guide to Python 3 Programming (Undergraduate Topics in Computer Science) Paperback – 30 September 2019 by John Hunt (Author)
PDF Download:

A Beginners Guide to Python 3 Programming for Undergraduate Topics in Computer Science by John Hunt PDF

This textbook on Python 3 explains concepts such as variables and what they represent, how data is held in memory, how a for loop works and what a string is. It also introduces key concepts such as functions, modules and packages as well as object orientation and functional programming. Each section is prefaced with an introductory chapter, before continuing with how these ideas work in Python.

Topics such as generators and coroutines are often misunderstood and these are explained in detail, whilst topics such as Referential Transparency, multiple inheritances and exception handling are presented using examples.

A Beginners Guide to Python 3 Programming provides all you need to know about Python, with numerous examples provided throughout including several larger worked case studies illustrating the ideas presented in the previous chapters.
Buy: A Beginners Guide to Python 3 Programming (Undergraduate Topics in Computer Science) Kindle Edition by John Hunt (Author) Format: Kindle Edition
PDF Download :

Maximum Occurring character | Python | Castor Classes

Code:


t=int(input());
i=0;
while(i<t):
    a=input();
    character='';
    count=0;
    output=a[0];
    max=a.count(output);
    for ig in a:
        c=a.count(ig);
        if(c>max):
            max=c;
            output=ig;
        elif(c==max and output>ig):
            output=ig;
    print(output);
    i=i+1;

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

Join us : t.me/clcoding_python

Sum of Digits of a number | Python | Castor Classes

Code: t=int(input()); i=0; while(i<t): a=int(input()); w=str(a); e=list(w); output=0; for ij in e: output=output+int(ij); print(output); i=i+1;

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

Popular Posts

Categories

AI (27) Android (24) AngularJS (1) Assembly Language (2) aws (17) Azure (7) BI (10) book (4) Books (115) C (77) C# (12) C++ (82) Course (62) Coursera (179) coursewra (1) Cybersecurity (22) data management (11) Data Science (91) Data Strucures (6) Deep Learning (9) Django (6) Downloads (3) edx (2) Engineering (14) Excel (13) Factorial (1) Finance (5) 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 (747) Python Coding Challenge (207) 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