From Python to Java or C++? [closed]

I was learning Python 3 since the Last 2 years and I have covered many topics in python. And Python is the 1st ever language I have learnt ( i really had tough times to learn python)

Now, I want to participate in a coding contest like USACO, there python is not allowed so I want to learn Java/C++

But I am Confused about Which is the best way to learn and from where to learn? How long will it take to learn?should I learn Java Or C++ which one is better for future demand?

And How hard is it to transfer my python knowledge to Learn Java/C++?

About Me In Future, I would like to work with the Theoretical Computer Science and Solve Real World Problems and Develop New Technologies .

(I do not want to be Software Engineer )

Connecting to a Postgres Database over SSL using Sockets in Python

I am trying to connect to a Postgres Database using sockets to enforce a particular TLS version from the client in order to verify that the Database does not accept connections from the client which uses an older version of TLS like tlsv1.1. The connection is failing on handshake with the following error :


Traceback (most recent call last): File "", line 12, in ssl_version=ssl.PROTOCOL_TLSv1_2) File "<>/python3.6/lib/python3.6/", line 1232, in get_server_certificate with context.wrap_socket(sock) as sslsock: File "<>/python3.6/lib/python3.6/", line 407, in wrap_socket _context=self, _session=session) File "<>/python3.6/lib/python3.6/", line 817, in init self.do_handshake() File "<>/python3.6/lib/python3.6/", line 1077, in do_handshake self._sslobj.do_handshake() File "<>/python3.6/lib/python3.6/", line 689, in do_handshake self._sslobj.do_handshake() ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:852)

The following is a snippet of the code:

    import socket     import ssl          hostname = <DB_Endpoint>     context = ssl.create_default_context()          with socket.create_connection((hostname, 8200)) as sock:         with context.wrap_socket(sock, server_hostname=hostname) as ssock:             print(ssock.version())      

PS: I am just trying to figure out a way to test if the Postgres Server rejects a connection from a client which only has

Strings in python

How to find a specified letter follows an another letter or not. eg; the input is : ‘hi, how are you?’,’h’,’i’ then the output is true, because i followed by h at least one time .

Checking equality of integers: O(1) in C but O(log n) in Python 3?

Consider these equivalent functions in C and Python 3. Most devs would immediately claim both are O(1).

def is_equal(a: int, b: int) -> bool:   return a == b 
int is_equal(int a, int b) {   return a == b } 

But consider what is happening under the surface. Integers are just binary strings and, to determine equality, both languages will compare the strings bit-by-bit. In either case this scan is O(b) where b is the number of bits. Since integers have a constant size in bits in C, this is simply O(1).

In Python 3 however, integers do not have fixed size and the scan remains O(b) for the number of bits in the input, or O(log a) where a is the value of the input in base 10.

So if you’re analyzing code in Python, any time you compare two integers, you are embarking on a surprisingly complex journey of O(log n) with respect to the base 10 value of either number.

For me this raises several questions:

  1. Is this correct? I haven’t seen anyone else claim that Python compares ints in log time.
  2. In the context of conducting an interview, should you notice or care if a candidate calls this O(1)?
  3. Should you notice or care about this distinction in the real world?

Encryption (not hashing) of credentials in a Python connection string

I would like to know how to encrypt a database connection string in Python – ideally Python 3 – and store it in a secure wallet. I am happy to use something from pip. Since the connection string needs to be passed to the database connection code verbatim, no hashing is possible. This is motivated by:

  • a desire to avoid hard-coding the database connection credentials in a Python source file (bad for security and configurability);
  • avoid leaving them plain-text in a configuration file (not much better due to security concerns).

In a different universe, I have seen an equivalent procedure done in .NET using built-in machineKey / EncryptedData set up by aspnet_regiis -pe, but that is not portable.

Though this problem arises from an example where an OP is connecting via pymysql to a MySQL database,

  • the current question is specific neither to pymysql nor MySql, and
  • the content from that example is not applicable as a minimum reproducible example here.

The minimum reproducible example is literally

#!/usr/bin/env python3  PASSWORD='foo' 

Searching for this on the internet is difficult because the results I get are about storing user passwords in a database, not storing connection passwords to a database in a separate wallet.

I would like to do better than a filesystem approach that relies on the user account of the service being the only user authorized to view what is otherwise a plain-text configuration file.

Related questions

  • Securing connection credentials on a web server – but that requires manual intervention on every service start, which I want to avoid
  • Security while connecting to a MySQL database using PDO – which is PHP-specific and does not discuss encryption

The wonders for data science and python

     Data science involves the use of advanced math techniques, statistics, and big data. however, data science also involves helping you make smart decisions, creating suggestions for options based on previous choices, and making robots see objects.                                                                                                                                  in fact, people use data science in so many different ways that you literally can't look anywhere or do anything without feeling the effects of data science on your life.                                    in short , data science is the person behind the partition in the experience of the wonderment of technology.                                                                                           without data science, much of what you expect as typical and expected to-day would n't even be possible.[EXTRACT OF A BOOK-PYTHON FOR DATA SCIENCE FOR DUMMIES  BY JOHN PAUL MUELLER AND LUCA MASSARON}                                                                                   But I would like to know the match between data science and python, how to create the connection between Python and data science. as far as I know, python is a programming language.