Pythonista

Pythonista

18 Articles Published

Articles by Pythonista

Page 2 of 2

How to insert a Python tuple in a MySQL database?

Pythonista
Pythonista
Updated on 18-Feb-2020 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 3, you need to install PyMySQL module. Then you can set up the connection using following statementsimport PyMySQL # Open database connection db = PyMySQL.connect("localhost", "root", "", "test" ) # prepare a cursor object using cursor() method cursor = db.cursor()Next step is to set up the insert query using data ...

Read More

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

Pythonista
Pythonista
Updated on 10-Feb-2020 5K+ 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 your case, error message indicating a.out is not executable is appearing. See the properties of a.out and make it executable (if not already) by following command −$ chmod +x a.outYou may require sudo privilege for this. In all probability this should work. all the best

Read More

How to convert a string to a integer in C

Pythonista
Pythonista
Updated on 27-Jan-2020 709 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

Read More

compareTo() definition mistake?

Pythonista
Pythonista
Updated on 30-Jul-2019 218 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.

Read More

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

Pythonista
Pythonista
Updated on 30-Jul-2019 453 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 mandatory. Hence, C++ is not a pure object oriented language bu Java is a completely object oriented language.

Read More

How to write string functions in Java?

Pythonista
Pythonista
Updated on 30-Jul-2019 193 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) { char arr[]=str.toCharArray(); for (char ch:arr) { if (Character.isDigit(ch)) { return true; } } return false; }2.) take ...

Read More

Is there a “not equal” operator in Python?

Pythonista
Pythonista
Updated on 30-Jul-2019 463 Views

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

Read More

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

Pythonista
Pythonista
Updated on 30-Jul-2019 1K+ 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 the language more elegant or easier to learn. They'd just save a few hasty folks some typing while making others who have to read/maintain their code wonder what it means".

Read More
Showing 11–18 of 18 articles
« Prev 1 2 Next »
Advertisements