Python Programming

Python was first released in 1991, it is an high-level programming language. It was created by Python Software Foundation. The language is influenced by a number of programming language such as C, Lisp, Perl, Java and others.

360 Questions
Microsoft Windows
Java Programming
Numerical Analysis and Simulation
Python Programming

How do you code a program to find kaprekar number?


class kaprekar


public static void main(String args[])throws IOException


BufferedReader br=new BufferedReader(new InputStreamReader(;

System.out.println("Enter any number");

int n=Integer.parseInt(br.readLine());

int t=n,count=0;






int s=t*t;

int p=(int)Math.pow(10,count);

int ld=s%p;

int minus=s-ld;

int fd=minus/p;

int sum=fd+ld;



System.out.println("Kaprekar Number");




System.out.println("Not a Kaprekar number");




Internet Slang
Windows 7
Python Programming

How do you add list in python?

>>> list1 = [3,5]

>>> list2 = ['foo','bar']

>>> ans = list1

>>> print ans

[3, 5]

>>> for var in list2:


>>> print ans

[3, 5, 'foo', 'bar']

this might not be the most efficient way to add lists together but it works.

ans.append(var) means to add the variable 'var' to the end of list 'ans'. the reason I put this in a for loop is if I just said ans.append(list2), the answer would be [3,5,['foo,bar']].

Python Programming

What is the Python programming language?

Python is an interpreted, interactive, object-oriented programming language. It is often compared to Tcl, Perl, Scheme or Java. it is a scripting language like php or asp for developing applications Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. Its high-level built in data structures, combined with dynamic typing and dynamic binding, make it very attractive for Rapid Application Development, as well as for use as a scripting or glue language to connect existing components together. Python's simple, easy to learn syntax emphasizes readability and therefore reduces the cost of program maintenance. Python supports modules and packages, which encourages program modularity and code reuse. The Python interpreter and the extensive standard library are available in source or binary form without charge for all major platforms, and can be freely distributed.

Computer Programming
C++ Programming
Python Programming

What are the advantages of Python over C plus plus?

Python is an interpreted high-level language and interpreters are available for Windows, Mac OS X and Unix. Thus the same code can be executed upon these different platforms with no changes to code. By contrast, C++ must be compiled separately for each platform and all machine-specific code must be filtered out of each compilation, which puts an increased workload upon the programmer.

As an interpreted language Python is more direct and convenient, it can be used interactively or can be used to build complete programs, without any of the lengthy compilation and linking procedures involved in C++.

Python's data types are high-level and extremely flexible, unlike the strong data typing that is strictly enforced by C++. As such there is no need to declare variables before using them. However, the flexibility comes at a cost in increased memory consumption.

The flexibility of the language and high-level nature of the data types means Python is much easier to learn than C++, and therefore more accessible to non-programmers.

The main disadvantage of Python compared to C++ is that it doesn't perform well. However, the same can be said of all interpreted languages, including Java. C++ will always perform better because code is compiled to native machine code, but requires more effort on the part of the programmer. However, the results are comparable to that of low-level assembly.

Python Programming

How do you write a program for Armstrong numbers in python using for loop?

def isArmstrongNumber(num):

factor = len(str(num))

res = 0

for digit in str(num):

res = res + (int(digit)**factor)

if (num == res):

return True


return False

for i in range(1000):

if isArmstrongNumber(i):

print i,


0 1 2 3 4 5 6 7 8 9 153 370 371 407

Java Programming
Python Programming

Sort array in ascending descending order in python?

Using sorted(array,reverse=True)

Computer Networking
Python Programming

When a module is executing?

You can execute a python module directly. In addition, when you are executing a module that import other modules (that import other modules...), all the modules will executed.

Database Programming
Python Programming

Why is database useful?

A database is a program that stores information. Such info can be sorted and retrieved in whatever output the operator requires. A common use for a database is to store the names and addresses of members belonging to a club, etc. The club Secretary or Treasurer can sort the membership database to show those member who have not yet renewed their membership subscription.

A commercial company may have a database showing customers' names, addresses and other details, their past purchases, their credit state, and so on.

Computer Programming
Python Programming

How do you write a horoscope program on python?

Hi gys, are you looking to write a program to know the sign depends on the birth date or horoscope on python? write down following codes on python, those will make a nice program.

#This program will get the horoscope sign.

def getSign():

name = raw_input ("Enter Your Name: ")

month = raw_input("Enter Birth Month: ")

day = int(raw_input("Enter Birth Day of Month: "))

if month "y":


letter = raw_input("Go again? (y/n): ")

Computer Programming
Math and Arithmetic
Python Programming

What is floor division in Python?

Floor division is division where the answer is rounded down. For example, 5/2 in floor division is not 2.5, but 2. In Python 2, floor division is the default. In Python 3, the floor division operator is //.

Python 2:

>>> 5/2


>>> 5.0/2


Python 3:

>>> 5/2


>>> 5//2


Java Programming
C Programming
Python Programming

What is the section of a select case statement that is branched to if none of the case values match the expression listed after the select statement?

The default case.

Java Programming
Python Programming

Is python is pure platform independent?

Yes! The Python standard library takes considerations to what platform you are on, especially in the OS module. Now, if you are opening files (or walking the filesystem, etc) you need to take care that your filepaths are system independent, if you want that.

Python Programming

What is the use of colon in python after loop and condition?

it starts a new code block. all the indented code after the colon will be considered as one block.

for example, in loops it means that all the indented code after the colon will be run on each iteration.


for i in range(4):

# this code will run 4 times

# this code will be ran once.

Python Programming

What are some features of the python programming language?

Here are some of the features I like:

  • Fairly simple, and easy to learn, compared with other languages.
  • Supported on many platforms.
  • The language in general requires less statements to achieve something than many other languages.
  • The scope of a for, while, if, etc. is defined by indentation. That is, no special symbols are used to indicate the end of such a block. This also means you must indent correctly.
  • A procedure can return more than one value, like this:
    • In the procedure: return a, b
    • Calling the procedure: x, y = myprocedure(...)
    • I guess that technically, the procedure returns a single item (a list), but the language syntax makes it easy to assign the parts of this list to more than one variable.
  • Built-in support for complex numbers.
  • Built-in support for numbers of an arbitrary size.

I want to add more info, like



Cross-platform and Open Source

Also as of March 2016, Python had the highest year-on-year job demand growth (at 19%) among all programming languages. On Angel List, Python stands as the 2nd most demanded skill and also the skill with the highest average pay offered.

Python Programming

What are the translator used of python programming languange?

interactive interpreter more like a "shell" (if you're

a unix person).

C++ Programming
Python Programming

What is the binary number for 128 64 32 16 8 4 2 1?

In binary numbers...
1 = 1
2 = 10
4 = 100
8 = 1000
16 = 10000
32 = 100000
64 = 1000000
128 = 10000000

C Programming
Delphi and Pascal Programming
Python Programming

What is bootstraping in compiler design?

Bootstrapping is a means of developing a compiler in the target programming language which it is intended to compile.

Computer Programming
Python Programming

Write a program to print your name hundred time?

int count;
char nam[9999];
printf("\n Enter your name : ");
for (count=1;count<=100;count++)
printf("\n %c",nam);

/*comment - You may no use \n in the second printf if u don't want the name to printed in a new line everytime....also u can rewrite it as printf( "\n%d. %c",count,nam); if u want to number the no. of times the name is printed*/

Python Programming

What are the advantages and disadvantages of Visual Basic?

Visual basic is a proprietary programming language written by Microsoft, so programs written in Visual basic cannot, easily, be transferred to other operating systems. There are versions of Basic that run on several operating systems, but they aren't direct clones of VB so some work would have to be done. Visual Basic is built around the .NET environment used by all Microsoft Visual languages, so there is very little that can't be done in Visual Basic that can be done in other languages (such as C#). Visual Basic only really exists as a high-level Windows programming language - for writing Windows applications. Whereas other languages (particularly the "C" family of C, C++ and C#) have a life outside of Windows and are used for everything from writing device drivers or "embedded" systems up to large applications. There are some, fairly minor disadvantages compared with C: C has better declaration of arrays - its possible to initialise an array of structures in C at declaration time; this is impossible in VB. in combination if tests: if A and B then endif In C, it is defined that A is evaluated first, then B. Visual Basic doesn't guarantee the order of evaluation; this makes some programming a bit more awkward; in C, the following is safe: if Inst>0 and Array(inst) =5 then


// do stuff

} as the Inst>0 test is always done first, in visual basic it becomes: if Inst > 0

if Array(inst) = 5 then

' do stuff


endif The advantages of VB are the ease of learning - the syntax is simpler than other languages (although it can be argued that C has more flexibility). The visual environment is excellent (although that's common to all the visual languages). It's widely used and, therefore, well understood.

Java Programming
C Programming
Python Programming

Write a multiplication table of using while loop upto 10?



void main()


int no;


printf("enter the number==>");


C Programming
Python Programming

Write a program in c language to draw a diamond shaped if you give the number?

Hey, It is not the exact logic for a given program.

Here i m giving the code with minimum number of executing steps.

also i m sure that there doesn't exist any other way to print the same Diamond such that code executing steps will be less than mine.

It is not copied from any website, book etc.


void main()


int n,i,s,k,flagReverce=0;

printf("Enter the no. of rows\n");

scanf("%d", &n);

for (i=1; i>=1; i++)


for (s=n; s>i; s-)

printf(" ");

for(k=1; k<(i*2)-1; k++)



if (i == n)

flagReverce = 1

if (flagReverce = 1)




Python Programming

What is the purpose of the flag variable in a bubble sort?

to eliminate unnecessary swaps to eliminate unnecessary comparisons to stop as soon as the list is sorted to sort an array of unknown size

Python Programming

What does the exclamation mark do on Python?

we use exclamation mark for

"not equal to" function.

for example: if we want to write 3 is not equal to 4

Python Programming

Can you help me finish this python function?

Seriously people. Is it to much to ask that you read the question before submitting?

It would help to know what function you need help finishing.

Python Programming

How do you make a simple Python RPG game?

I actually am working on one right now. what I'm doing is I'm using pygame. pygame lets you open a separate window and have objects with it. you can look through the pygame documentation and it will teach you how to use it.


Copyright © 2020 Multiply Media, LLC. All Rights Reserved. The material on this site can not be reproduced, distributed, transmitted, cached or otherwise used, except with prior written permission of Multiply.