Monday 4 May 2020
If Expressions in Python
Author May 04, 2020 Python No comments
if else command | Python
https://www.youtube.com/watch?v=9GJWK...
Java code used in this video:
import java.util.*;
public class Hello {
public static void main(String args[])
{
Scanner obj=new Scanner(System.in);
int x=obj.nextInt();
String s=(x%2==0)?"Even":"Odd";
System.out.println(s);
}
}
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...
Separate 0’s and 1’s in an array | Python
Author May 04, 2020 Python No comments
https://www.youtube.com/watch?v=egq7Z..
Code:
l=int(input());
i=0;
m=[];
zeros=0;
while(i<l):
y=int(input());
if(y==0):
zeros+=1;
m.append(y);
i+=1;
i=0;
while(i<l):
if(i<zeros):
m[i]=0;
else:
m[i]=1;
i=i+1;
print(m);
Telegram: https://t.me/clcoding_python
https://www.facebook.com/pirawenpython/
https://www.facebook.com/groups/piraw...
Find first set bit | Python
Author May 04, 2020 Python No comments
https://www.youtube.com/watch?v=egq7Z...
Code:
t=int(input());
i=0;
while(i<t):
a=int(input());
rs=bin(a)[2:];
y=list(rs);
y.reverse();
if('1' in y):
io=y.index('1');
print(io+1);
else:
print(0);
i=i+1;
Telegram: https://t.me/clcoding_python
https://www.facebook.com/pirawenpython/
https://www.facebook.com/groups/piraw...
Sunday 3 May 2020
Integer and Decimal value in C#
Irawen May 03, 2020 C# No comments
- C# Integer Datatypes
- C# Decimal Datatypes
- We can only store whole number in them
- Whole Number mean number without any decimal such as 34, 204, 35 etc
- byte
- short
- int
- long
- Byte
- sbyte can store value between -128 and 127.
- byte can store value between 0 and 255.
- short can store between -32768 and 32767.
- ushort can store between 0 and 65535.
- int can stor value between -2147483648 and 2147483647.
- uint can store value between0 and 4294967295.
- long can store value between -9223372036854775808 and 9223372036854775807.
- ulong can store value between 0 and 18446744073709551615.
- General Syntax
DataType VariableName = value;
Examples
- sbyte scoreSbyte;
- byte ageByte;
- short studentIdShort = 5;
- int studentIdInteger = 43;
- We can store decimal numbers in them
- We can also store Whole number in them
- For example , 34.5, 204.3, 35.7 etc.
- float
- double
- float salaryFloat = 101.5f;
- decimal salaryDecimal = 101.25m;
- double salaryDouble = 101.5;
Saturday 2 May 2020
List membership Testing using in | Part 8 | Python
Author May 02, 2020 Python No comments
Problem Link: Check If N and Its Double Exist: https://leetcode.com/problems/check-i... Python for beginners: https://www.youtube.com/watch?v=egq7Z...
Prime Number of Set Bits in Binary Representation | Python
Author May 02, 2020 Python No comments
Telegram: https://t.me/clcoding_python
https://www.facebook.com/pirawenpython/
Brian Kernighan’s Algorithm | Python
Author May 02, 2020 Python No comments
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
Author May 02, 2020 Python No comments
Python for beginners: https://www.youtube.com/watch?v=egq7Z...
Telegram: https://t.me/clcoding_python https://www.facebook.com/pirawenpython/
Move Zeroes | Python
Author May 02, 2020 Python No comments
Python for beginners: https://www.youtube.com/watch?v=egq7Z...
Telegram: https://t.me/clcoding_python https://www.facebook.com/pirawenpython/
Counting Elements | Python
Author May 02, 2020 Python No comments
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
Author May 02, 2020 Python No comments
Telegram: https://t.me/clcoding_python
Friday 1 May 2020
Python Input() Function
Irawen May 01, 2020 Python No comments
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
Author April 30, 2020 Python No comments
Join: t.me/clcoding_python
Relationship between binary representation of n & n-1 | Python
Author April 30, 2020 Python No comments
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
Author April 30, 2020 Python No comments
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%2==0
True
f=11;
f%2==0
False
Like us: https://www.facebook.com/pirawenpython/
Tuple in Python | Part 2
Author April 30, 2020 Python No comments
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?
Nested List & Matrix | List in Python | Part 7
Author April 30, 2020 Python No comments
#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
Popular Posts
-
1. What is the output of following Python code? a = 'a' print(int(a, 16)) Solution and Explanation: Let's break down the expr...
-
What you'll learn Automate tasks by writing Python scripts Use Git and GitHub for version control Manage IT resources at scale, both for...
-
1. what is the output of following Python code? my_string = '0x1a' my_int = int(my_string, 16) print(my_int) Solution and Explanatio...
-
What you'll learn Understand why version control is a fundamental tool for coding and collaboration Install and run Git on your local ...
-
What will be the output of the following code snippet? print(bool("")) Answer: False Explanation: An empty string is considered to...
-
Software Architecture Patterns for Serverless Systems - Second Edition: Architecting for innovation with event-driven microservices and mi...
-
Code: x = [1, 2, 3] x.insert(1, 4) print(x) Solution and Explanation: Let's break it down step by step: Creating the list x: x = [1, ...
-
Code: def rem(a, b): return a % b print(rem(3,7)) Solution and Explanation: Let's break down the code step by step: def rem(a, b)::...
-
Introduction to Statistics In the age of big data, understanding statistics and data science concepts is becoming increasingly crucial acros...
-
# 10 different data charts using Python pip install matplotlib seaborn # 1. Line Chart: import matplotlib.pyplot as plt x = [ 1 , 2 , 3 ...