programming like c, c++, java,python learn in free

  • This is default featured slide 1 title

    Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

  • This is default featured slide 2 title

    Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

  • This is default featured slide 3 title

    Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

  • This is default featured slide 4 title

    Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

  • This is default featured slide 5 title

    Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

Wednesday, April 22, 2020

Questions for c programming

You will be given a square matrix of N rows and N columns (1 <= N <= 1000) containing positive and negative integers with absolute value not larger than 1000. You are required to compute the greatest sum achievable by walking a path, starting at any cell of the matrix and always moving downwards or rightwards. Additionally, you have to report the number of times that value is achievable. N will be in the first line of the input. N lines follow with N integers each. You should output a single line with two integers separated by a single blank space: first one is the greatest sum, second one is the number of times this value can be reached.

Case 1:

For the input provided as follows:

5
3 1 -2 1 1
-6 -1 4 -1 -4
1 1 1 1 1
2 2 2 2 2
1 1 1 1 1

Output of the program will be:

15 1
Share:

Monday, April 20, 2020

Number in python

If you’ve done any programming or scripting in the past, some of the object types in
Table 4-1 will probably seem familiar. Even if you haven’t, numbers are fairly straight-
forward. Python’s core objects set includes the usual suspects: integers that have no
fractional part, floating-point numbers that do, and more exotic types—complex 
numbers with imaginary parts, decimals with fixed precision, rationals with numerator and
denominator, and full-featured sets. Built-in numbers are enough to represent most
numeric quantities—from your age to your bank balance—but more types are available
as third-party add-ons.
Although it offers some fancier options, Python’s basic number types are, well, basic.
Numbers in Python support the normal mathematical operations. For instance, the
plus sign ( + ) performs addition, a star ( * ) is used for multiplication, and two stars ( ** )
are used for exponentiation:
>>> 123 + 222
# Integer addition
345
>>> 1.5 * 4
# Floating-point multiplication
6.0
>>> 2 ** 100
# 2 to the power 100, again
1267650600228229401496703205376
Notice the last result here: Python 3.X’s integer type automatically provides extra 
precision for large numbers like this when needed (in 2.X, a separate long integer type
handles numbers too large for the normal integer type in similar ways). You can, for
instance, compute 2 to the power 1,000,000 as an integer in Python, but you probably
shouldn’t try to print the result—with more than 300,000 digits, you may be waiting
awhile!
>>> len(str(2 ** 1000000))
301030
# How many digits in a really BIG number?
This nested-call form works from inside out—first converting the ** result’s number
to a string of digits with the built-in str function, and then getting the length of the
resulting string with len . The end result is the number of digits. str and len work on
many object types; more on both as we move along.
On Pythons prior to 2.7 and 3.1, once you start experimenting with floating-point
numbers, you’re likely to stumble across something that may look a bit odd at first
glance:
# repr: as code (Pythons < 2.7 and 3.1)
>>> 3.1415 * 2
6.2830000000000004
>>> print(3.1415 * 2)
6.283
# str: user-friendly
The first result isn’t a bug; it’s a display issue. It turns out that there are two ways to
print every object in Python—with full precision (as in the first result shown here), and
in a user-friendly form (as in the second). Formally, the first form is known as an object’s
as-code repr , and the second is its user-friendly str . In older Pythons, the floating-point
repr sometimes displays more precision than you might expect. The difference can also
matter when we step up to using classes. For now, if something looks odd, try showing
it with a print built-in function call statement.
Better yet, upgrade to Python 2.7 and the latest 3.X, where floating-point numbers
display themselves more intelligently, usually with fewer extraneous digits—since this
book is based on Pythons 2.7 and 3.3, this is the display form I’ll be showing throughout
this book for floating-point numbers:
# repr: as code (Pythons >= 2.7 and 3.1)
>>> 3.1415 * 2
6.283
Besides expressions, there are a handful of useful numeric modules that ship with
Python—modules are just packages of additional tools that we import to use:
>>> import math
>>> math.pi
3.141592653589793
>>> math.sqrt(85)
9.219544457292887
The math module contains more advanced numeric tools as functions, while the ran
dom module performs random-number generation and random selections (here, from a
Python list coded in square brackets—an ordered collection of other objects to be in-
troduced later in this chapter):
>>> import random
>>> random.random()
0.7082048489415967
>>> random.choice([1, 2, 3, 4])
1
Share:

Sunday, April 19, 2020

Flavors of Python

1) CPython:
It is the standard flavor of Python. It can be used to work with C lanugage Applications.

2) Jython OR JPython:
It is for Java Applications. It can run on JVM

3) IronPython:
It is for C#.Net platform

4) PyPy:
The main advantage of PyPy is performance will be improved because JIT compiler is
available inside PVM.

5) RubyPython
For Ruby Platforms

6) AnacondaPython
It is specially designed for handling large volume of data processing.


Share:

Constructor Concept(Python)


  • Constructor is a special method in python.
  • The name of the constructor should be __init__(self)
  • Constructor will be executed automatically at the time of object creation.
  • The main purpose of constructor is to declare and initialize instance variables.
  • Per object constructor will be exeucted only once.
  • Constructor can take atleast one argument(atleast self)
  • Constructor is optional and if we are not providing any constructor then python will provide default constructor.

Example:
 def __init__(self,name,rollno,marks):
self.name=name
self.rollno=rollno
self.marks=marks
Program to demonistrate Constructor will execute only once per Object:
class Test:
def __init__(self):
print("Constructor exeuction...")
def m1(self):
print("Method execution...")
t1=Test()
t2=Test()
t3=Test()
t1.m1()
Output:
Constructor exeuction...
Constructor exeuction...
Constructor exeuction...
Method execution...
Share:

Saturday, April 18, 2020

what is class?(python) with example

  1.  In Python every thing is an object. To create objects we required some Model or Plan
  2. or Blue print, which is nothing but class.
  3.  We can write a class to represent properties (attributes) and actions (behaviour) of object.
  4.  Properties can be represented by variables Actions can be represented by Methods.
  5. Hence class contains both variables and methods.


How to define a Class?
We can define a class by using class keyword.
Syntax:
class className:
''' documenttation string '''
variables:instance variables,static and local variables
methods: instance methods,static methods,class methods
Documentation string represents description of the class. Within the class doc string is
always optional. We can get doc string by using the following 2 ways.
1) print(classname.__doc__)
2) help(classname)
Example:
1) class Student:
2)
''''' This is student class with required data'''
3) print(Student.__doc__)
4) help(Student)
Share:

Unordered List

recentposts1
Powered by Blogger.

Text Widget

Featured Post

C programming Question and Answer Day-15

71. Program to check Niven number (Harshad number). #include<stdio.h> #include<conio.h> void main() {     int n, d, a, su...

Search This Blog

recent comments

recentcomments

Labels

[slideshow][technology]

vertical posts

[verticalposts][technology]

business

[business][grids]

ad space

ads 600

vehicles

[cars][stack]
[verticalposts][food]

our facebook page

about us

logo

Jupiter is a magazine responsive Blogger template. It has everything you need to make your blog stand out. This template is fully customizable and very flexible and we believe you will love it as much as we do.

Slide show

[people][slideshow]

health

[health][btop]

recent posts

recentposts1

Subscribe Us

random posts

randomposts2

Blog Archive

Recent Posts

top ads

Unordered List

recent

Pages

Theme Support

[socialcounter] [facebook][#][215K] [twitter][#][115K] [youtube][#][215,635] [rss][#][23M] [linkedin][#][21.5K] [instagram][#][600,300]