Title | Python unit one dis |
---|---|
Author | حنين بامطرف |
Course | Programming Fundamentals |
Institution | University of the People |
Pages | 2 |
File Size | 32.1 KB |
File Type | |
Total Downloads | 12 |
Total Views | 138 |
Learning Jornal unit one python...
Python3.10.0
>>> print 'Hello, World!' Output: Syntax Error: Missing parentheses in call to 'print'. Did you mean print('Hello, World!')? Explain: there must be parentheses before single quotes and at the end, print('Hello, World!'). print 'Hello, World!' it will work in Python 2. We can’t use it in Python 3.
>>> 1/2 Output: 0.5 Explain: the computer doesn't read this sign (/) as a fraction, although it reads it as a division sign. Python took the first integer, the operator, and the second integer.
>>>type(1/2) Output:
Explain: If we want to know the type of variable we use (type).
>>>print(01) Output: Syntax Error: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers.
Explain: The correct formula is to write an integer number is writing 0o. >>>print(0o1) Output: 1 Also, we can write 1/(2/3) Output: 1.5 Explain: When we use the division sign / correctly, the interpreter translates it correctly. But if we write the same code in Python2 it will be a bug, Python 2 just takes the first number....