Dalam pemrograman menggunakan bahasa pemrograman Python kita memiliki constant-constant yang sudah ada atau sudah built-in.
Built-in constant pada pemrograman Python adalah
- False
- True
- None
- NotImplemented
- Ellipsis
- __debug__
- quit
- exit
- copyright
- credits
- license
Contoh penggunaannya adalah seperti pada gambar di bawah ini
Tampilan di atas juga bisa dituliskan
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | Python 3.11.2 (tags/v3.11.2:878ead1, Feb 7 2023, 16:38:35) [MSC v.1934 64 bit (AMD64)] on win32 Type "help" , "copyright" , "credits" or "license" for more information. >>> print (False) False >>> print (True) True >>> print (None) None >>> print (NotImplemented) NotImplemented >>> print (Ellipsis) Ellipsis >>> print (__debug__) True >>> print (quit) Use quit() or Ctrl-Z plus Return to exit >>> print ( exit ) Use exit () or Ctrl-Z plus Return to exit >>> print (copyright) Copyright (c) 2001-2023 Python Software Foundation. All Rights Reserved. Copyright (c) 2000 BeOpen.com. All Rights Reserved. Copyright (c) 1995-2001 Corporation for National Research Initiatives. All Rights Reserved. Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam. All Rights Reserved. >>> print (credits) Thanks to CWI, CNRI, BeOpen.com, Zope Corporation and a cast of thousands for supporting Python development. See www.python.org for more information. >>> print (license) Type license() to see the full license text >>> |
Informasi lebih lanjut silahkan mengunjungi https://docs.python.org/3/library/constants.html .
Kunjungi www.proweb.co.id untuk menambah wawasan anda.
Built-in Constant pada Pemrograman Python