Pythonista has Published 42 Articles

How to insert a Python tuple in a MySQL database?

Pythonista

Pythonista

Updated on 18-Feb-2020 08:03:23

2K+ Views

Assuming that MySQL database named as test is present on server and a table named employee is also created. The table has five fields fname, lname, age, gender, and salary.A tuple object containing data of a record is defined ast1=('Mac', 'Mohan', 20, 'M', 2000)To establish interface between MySQL  and Python ... Read More

How to convert a Python for loop to while loop?

Pythonista

Pythonista

Updated on 11-Feb-2020 06:47:06

7K+ Views

Unlike while loop, for loop in Python doesn't need a counting variable to keep count of number of iterations. Hence, to convert a for loop into equivalent while loop, this fact must be taken into consideration.Following is a simple for loop that traverses over a rangefor x in range(5):   ... Read More

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

419 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

667 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

104 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

256 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

71 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

175 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

253 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

Advertisements