Pythonista has Published 40 Articles

C++ 'a.out' not recognised as a command

Pythonista

Pythonista

Updated on 10-Feb-2020 10:47:17

4K+ Views

Having entered following command from linux terminal −$ g++ helloworld.cppThe a.out file should be created in the current working directory if the compilation is successful. Check if a.out is created.To execute enter following from command line −$ ./a.outIn most cases, output of your source program is displayed. However, as in ... Read More

How to convert a string to a integer in C

Pythonista

Pythonista

Updated on 27-Jan-2020 12:41:27

453 Views

First extract characters from left bracket '(' using strchr() function.char *name="The Matrix(1999)"; char *ps; ps=strchr(name,'(');Then add each character within brackets () to an char arraychar y[5]=""; int  p; for (p=1;p

What are valid python identifiers?

Pythonista

Pythonista

Updated on 30-Sep-2019 09:00:47

706 Views

An identifier in a Python program is name given to various elements in it, such as keyword, variable, function, class, module, package etc. An identifier should start with either an alphabet (lower or upper case) or underscore (_). More than one alpha-numeric characters or underscore may follow.Keywords are predefined. They ... Read More

compareTo() definition mistake?

Pythonista

Pythonista

Updated on 30-Jul-2019 22:30:22

116 Views

The example works correctly. The compareTo() method is called by a string object and takes another string object as argument. The return value is integer and is difference in Unicode values of characters of respective strings when they are not equal. The value can be -ve, 0 or +ve.

Java is also not pure object-oriented like c++

Pythonista

Pythonista

Updated on 30-Jul-2019 22:30:22

288 Views

the main() method in Java code is itself inside a class. The static keyword lets the main() method which is the entry point of execution without making an object but you need to write a class. In C++, main() is outside the class and writing class it self is not ... Read More

How to write string functions in Java?

Pythonista

Pythonista

Updated on 30-Jul-2019 22:30:22

83 Views

1) take a string from the user and check contains atleast one digit or not:Extract character array from string using toCharArray() method. Run a for loop over each character in array and test if it is a digit by static method isDigit() of character classpublic static boolean chkdigit(String str) { ... Read More

Is there a “not equal” operator in Python?

Pythonista

Pythonista

Updated on 30-Jul-2019 22:30:22

215 Views

In Python 2.x as well as != symbols are defined as 'not equal to' operators. In Python 3, operator is deprecated.

How to stop an infinite loop safely in Python?

Pythonista

Pythonista

Updated on 30-Jul-2019 22:30:21

285 Views

Infinite loop is the one that doesn't stop on its own. It happens when the looping condition continues to remain true forever. In such a case, the loop must be forcibly stopped by pressing ctrl-C to generate keyboard interrupt

Why there is not do...while loop in Python?

Pythonista

Pythonista

Updated on 30-Jul-2019 22:30:21

960 Views

PEP 315 (Python Enhancement Proposal) to include do..while statement has been rejected because it doen't fit in the general format of indented block statement: indented block used by every other Python compound statement. In words of Guido Van Rossum -  "Please reject the PEP. More variations along these lines won't make ... Read More

How we can come out of an infinite loop in Python?

Pythonista

Pythonista

Updated on 30-Jul-2019 22:30:21

183 Views

A loop is said to be an infinite loop when it doesn't stop on its own. It needs to be forcibly stopped by pressing ctrl-C to generate keyboard interrupt.

Advertisements