Monday, December 30, 2019

Happy new year 2020 shayari wishes



“इस साल आपके घर खुशियों की हो धमाल,
दौलत की ना हो कमी आप हो जाए मालामाल,
मुस्कुराते रहो ऐसा हो सबका हाल,
तहे दिल से मुबारक हो आपको नया साल 20 20।"



“सबके दिलों में हो सबके लिए प्यार;
आने वाला हर दिन लाए खुशियों का त्यौहार,
इस उम्मीद के साथ आओ भूलके सारे गम,
न्यू इयर को हम सब करें वेलकम।”
नए साल 2020 कि शुभकामनाये ।

Python isinstance()

In Python isinstance() :

isinstance()

 The Python isinstance() function is used to check whether the object or variable is an instance of the specified class type or data type.

The isinstance() syntax and parameter:

isinstance(object, classinfo)

The isinstance() function checks if the object argument is an instance or subclass of classinfo class argument.

isinstance Parameters:

The isinstance() takes two arguments, and both are mandatory.

object:  The object/instance or variable to check. The object can be any class object or any variable name.

classinfo:  Class info is type name, class name or tuple of types and classes. For example, int, str, list, dict, or any user-created class.

Return Value from isinstance():
If an object or variable is of a specified type, then isinstance() return true otherwise false.


example:
marks = 71
result = isinstance(marks, int)
if result :
  print("Yes! given variable is an instance of type int")
else:
  print("No! given variable is not an instance of type int")

Output:
Yes! given varible is an instance of type int




Using Python isinstance(), you can do the followings:

1.Check the type of a Python variable is of a given type.
2.Verify whether a variable is a number or string.
3.Check if an object is an instance of a specified class.
4.Check whether variable or object is of dict type, list type, set type, tuple type.



isinstance() with Python Class
A isinstance() function test object is of a specified class type. isinstance() is working as a comparison operator because it compares the object with the specified class type.


The isinstance result will be true if the object is an instance of the given class type:

Example:

class Employee:
 
  def __init__(self, name, salary):
    self.name = name
    self.salary = salary

class Person:
 
  def __init__(self, name, sex):
    self.name = name
    self.sex = sex

emp = Employee("Tom", 10000)
per = Person("Cruise", "male")

print("Checking emp object is an instance of Employee")
if isinstance(emp, Employee) :
  print("Yes! given object is an instance of class Employee\n")
else:
  print("No! given object is not an instance of class Employee")

print("Checking per object is an instance of Employee") 
if isinstance(per, Employee) :
  print("Yes! given object is an instance of class Employee")
else:
  print("No! given object is not an instance of class Employee\n")

Output:
Checking emp object is an instance of Employee
Yes! a given object is an instance of class Employee

Checking per object is an instance of Employee
No! given object is not an instance of class Employee


The isinstance function works on the principle of the is-a relationship. The concept of an is-a relationship is based on class inheritance.

Happy New Year 2020


In this new year,your every wish and may God fill you with lots of happiness,
With these prayers, Happy New Year to you.

Happy new year full of new expectations,
Congratulations on this trick of happiness.
All your dreams are complete this year
Wishing you a very happy year.
Happy New Year 2020.

Saturday, December 28, 2019

Write an assembly program for 8085 microprocessor to find greatest between two numbers


Write an assembly program for 8085 microprocessor to find greatest between two numbers




Program:


MVI B, 30H
MVI C, 40H
MOV A, B
CMP C
JZ EQU
 JC GRT
 OUT PORT1
 HLT

EQU: MVI A, 01H
 OUT PORT1
 HLT
GRT: MOV A, C
 OUT PORT1
 HLT

Write an assembly program for 8085 microprocessor to multiply a number by 8

Write an assembly program for 8085 microprocessor to multiply a number by 8


Program:

MVI A, 30H
RRC
RRC
RRC
OUT PORT1
HLT

Write a program for 8085 microprocessor to arrange first 10 numbers from memory address 3000H in an ascending order.

Write a program for 8085 microprocessor to arrange first 10 numbers from memory address 3000H in an ascending order.


Answer: 


MVI B, 09                  :"Initialize counter"     
START                       :"LXI H, 3000H: Initialize memory pointer"
MVI C, 09H               :"Initialize counter 2"
BACK: MOV A, M   :"Get the number"
INX H                        :"Increment memory pointer"
CMP M                      :"Compare number with next number"
JC SKIP                     :"If less, don’t interchange"
JZ SKIP                     :"If equal, don’t interchange"
MOV D, M
MOV M, A
DCX H
MOV M, D
INX H                      :"Interchange two numbers"
SKIP:DCR C           :"Decrement counter 2"
JNZ BACK              :"If not zero, repeat"
DCR B                     :"Decrement counter 1"
JNZ START
HLT                         :"Terminate program execution"


Friday, December 27, 2019

To be happy:

To be happy:

Always be happy you keep yourself happy by doing the right thing you what to do.
Happiness is the feeling of getting joy in what you are doing.
A smile keeps you happy which can make your life ,always smile on your face is not easy way there may be downs where you need to keep yourself strong mentally as well as physically.
Make a habit to be always happy with a smile on your face.Think that what will be the last of all this id death which everyone will face ,some may face before you some after you ,so why to worry enjoy your life.
After your death how will you can be happy as life is once. Birthday is always wished Happy birthday so make every day your birthday which will make your everyday happy i.e. Happy Everyday.
To keep yourself happy depends on how much time you want to be as if you think about yourself it will make only you happy for sometime but if you help others to make their life happy it will make you happy for lifetime.

Python program to check if a string is palindrome or not

Python program to check if a string is palindrome or not

Answer:

my_str = 'Madam'
my_str = my_str.casefold()

rev_str = reversed(my_str)

if list(my_str) == list(rev_str):
   print("The string is a palindrome.")
else:
   print("The string is not a palindrome.")


Output:

The string is a palindrome.

C++ code to implement Sierpinski Triangle using Graphics

C++ code to implement Sierpinski Triangle using Graphics
 
#include  
#include  
#include  
 
#define Y 900
#define X 1600

void triangle(float x, float y,
              float h, int colorVal)
{
    setcolor(colorVal % 15 + 1);
 
    for (float delta = 0; delta > -5; delta -= 1) {
        line(x - (h + delta) / sqrt(3),
             y - (h + delta) / 3,
             x + (h + delta) / sqrt(3),
             y - (h + delta) / 3);
        line(x - (h + delta) / sqrt(3),
             y - (h + delta) / 3,
             x,
             y + 2 * (h + delta) / 3);
        line(x,
             y + 2 * (h + delta) / 3,
             x + (h + delta) / sqrt(3),
             y - (h + delta) / 3);
    }
}
 

void trianglev2(float x, float y,
                float h, int colorVal)
{
    setcolor(colorVal % 15 + 1);
 
    for (float delta = 0; delta > -1 + 5; delta -= 1) {
 
        line(x - (h + delta) / sqrt(3),
             y + (h + delta) / 3,
             x + (h + delta) / sqrt(3),
             y + (h + delta) / 3);
        line(x - (h + delta) / sqrt(3),
             y + (h + delta) / 3,
             x,
             y - 2 * (h + delta) / 3);
        line(x,
             y - 2 * (h + delta) / 3,
             x + (h + delta) / sqrt(3),
             y + (h + delta) / 3);
    }
}
 

int drawTriangles(float x = X / 2,
                  float y = 2 * Y / 3,
                  float h = Y / 2,
                  int colorVal = 0)
{
 
    if (h < 5) {
        return 0;
    }
 
    if (x > 0 && y > 0 && x < X && y < Y) {
        triangle(x, y, h, colorVal);
    }
 
    drawTriangles(x,
                  y - 2 * h / 3,
                  h / 2,
                  colorVal + 1);
    drawTriangles(x - h / sqrt(3),
                  y + h / 3,
                  h / 2,
                  colorVal + 1);
    drawTriangles(x + h / sqrt(3),
                  y + h / 3,
                  h / 2,
                  colorVal + 1);
 
    return 0;
}
 
int main()
{
    initwindow(X, Y);
    trianglev2(X / 2, 2 * Y / 3, Y, 2);
 
    drawTriangles();
    getch();
    closegraph();
 
    return 0;

Python program to sort alphabetically the words form a string provided by the user

Python program to sort alphabetically the words form a string provided by the user

Answer:

my_str = input("Enter a string: ")
words = my_str.split()
words.sort()
print("The sorted words are:")
for word in words:
print(word)

Output:
Enter a string: Hello this Is an Example
The sorted words are:
Example
Hello
Is
an
this

Featured posts

Happy Independence Day August 15th

 Here's a message for India's Independence Day (August 15th): "शुभ स्वतंत्रता दिवस! आजादी की 79वीं वर्षगांठ पर, आइए हम अपने देश...

Popular posts