The difference between python and c
The differences between python and C are as follows
1. Different language types.
Python is a dynamically typed language and a strongly typed language. They determine the type of a variable the first time you assign a value to it. C is a statically typed language, a language in which data types are determined at compile time. Most statically typed languages ensure this by requiring that the data type of any variable be declared before its use.
2. The object mechanism is different.
All data in Python are represented by objects or relationships between objects. Functions are objects, strings are objects, and everything is the concept of an object. Every object has three properties: entity, type and value.
There is no concept of object in C, only "data representation". For example, if there are two int variables a and b, and you want to compare the sizes, you can use a == b to judge, but if there are two int variables a and b, you can use a == b to judge. string variables a and b, you have to use strcmp to compare, because at this time, a and b are essentially pointers to strings. If you compare directly with ==, what is compared is actually the value address stored in the pointer. .
3. Variable types are different.
Python has six standard data types: Number, String, List, Tuple, Sets, and Dictionary. There are four types of number types: integers, Boolean types, floating point numbers, and complex numbers. C language can also be divided into four categories: basic types, enumeration types, void types, and derived types. Basic types: integer type, floating point type.
4. The methods of using function libraries are different.
To use that library function in C language, you need to introduce the header file using include, and when you need to introduce other modules or functions in python, you need to use import.
The different mechanism between the two is that include in C language tells the preprocessor that the contents of the file specified by this include should appear as a local source file, while import in python can be imported through a simple import , or import numpy as np.
5. Global variables are different.
In C language, declare global variables. If the value is constant, you can directly declare it with #define. If you only declare global variables and the value of the variable is variable, then it can be directly similar to int a. .
In python, when declaring a global variable, you need to add global, similar to global a. When using it in a function, you need to declare global a first. Otherwise, if a is used directly, python will re-create a new local object. And assign the new value to him, the value of the original global variable does not change.
The above is the detailed content of The difference between python and c. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Solution to permission issues when viewing Python version in Linux terminal When you try to view Python version in Linux terminal, enter python...

How to teach computer novice programming basics within 10 hours? If you only have 10 hours to teach computer novice some programming knowledge, what would you choose to teach...

How to avoid being detected when using FiddlerEverywhere for man-in-the-middle readings When you use FiddlerEverywhere...

When using Python's pandas library, how to copy whole columns between two DataFrames with different structures is a common problem. Suppose we have two Dats...

How does Uvicorn continuously listen for HTTP requests? Uvicorn is a lightweight web server based on ASGI. One of its core functions is to listen for HTTP requests and proceed...

Fastapi ...

Understanding the anti-crawling strategy of Investing.com Many people often try to crawl news data from Investing.com (https://cn.investing.com/news/latest-news)...

Using python in Linux terminal...
