Tutorial Gateway

  • C
  • C#
  • Java
  • Python
  • SQL
  • MySQL
  • Js
  • BI Tools
    • Informatica
    • Talend
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • R Tutorial
    • Alteryx
    • QlikView
  • More
    • C Programs
    • C++ Programs
    • Go Programs
    • Python Programs
    • Java Programs

Python Dictionary keys function

by suresh

Python keys Dictionary function is used to return the list of available keys in a dictionary (total keys). In this section, we discuss how to use this Dictionary keys function. The syntax behind this Dictionary keys function is:

dictionary_name.keys()

Python Dictionary keys Example

The dictionary key function returns the list of keys available in a given dictionary. The below dictionary code print the keys in amp, and empl.

TIP: Please refer to the Dictionary to understand Python Dictionaries.

# Python Dictionary keys Example

emp = {'name': 'Kevin', 'age': 25 , 'job': 'HR', 'Sal': 725000}
print("Dictionary: ", emp)

# Print Keys
print("\nDictionary Keys: ", emp.keys())

# Creating an Empty Dictionary
empl = {}
print("Dictionary: ", empl)

# Print Keys
print("\nDictionary Keys: ", empl.keys())
Python Dictionary keys 1

keys in a Dictionary Example 2

In this program, we are going to insert a new value into the dictionary and print keys. Next, we updated a value and displayed the dictionary keys.

# Python Dictionary keys Example

emp = {'name': 'Kevin', 'age': 25 , 'job': 'HR'}
print("Dictionary: ", emp)

# Print Keys
print("\nDictionary Keys: ", emp.keys())

# Print Keys
emp['age'] = 27
print("\nDictionary Keys: ", emp.keys())

# Print Keys
emp['Sal'] = 725000
print("\nDictionary Keys: ", emp.keys())
Python Dictionary keys 2

Placed Under: Python

  • Download and Install Python
  • Python Arithmetic Operators
  • Python Assignment Operators
  • Python Bitwise Operators
  • Python Comparison Operators
  • Python Logical Operators
  • Python If Statement
  • Python If Else
  • Python Elif Statement
  • Python Nested If
  • Python For Loop
  • Python While Loop
  • Python Break
  • Python Continue
  • Python Dictionary
  • Python datetime
  • Python String
  • Python Set
  • Python Tuple
  • Python List
  • Python List Comprehensions
  • Python Lambda Function
  • Python Functions
  • Python Types of Functions
  • Python Iterator
  • Python File Handling
  • Python Directory
  • Python Class
  • Python classmethod
  • Python Inheritance
  • Python Method Overriding
  • Python Static Method
  • Connect Python and SQL Server
  • Python SQL Create DB
  • Python SQL Select Top
  • Python SQL Where Clause
  • Python SQL Order By
  • Python SQL Select Statement
  • Python len Function
  • Python max Function
  • Python map Function
  • Python print Function
  • Python sort Function
  • Python range Function
  • Python zip Function
  • Python Math Functions
  • Python String Functions
  • Python List Functions
  • Python NumPy Array
  • NumPy Aggregate Functions
  • NumPy Arithmetic Operations
  • Python Numpy Bitwise operators
  • Numpy Comparison Operators
  • Numpy Exponential Functions
  • Python Numpy logical operators
  • Python numpy String Functions
  • NumPy Trigonometric Functions
  • Python random Array
  • Python numpy concatenate
  • Python numpy Array shape
  • Python pandas DataFrame
  • Pandas DataFrame plot
  • Python Series
  • Python matplotlib Histogram
  • Python matplotlib Scatter Plot
  • Python matplotlib Pie Chart
  • Python matplotlib Bar Chart
  • Python List Length
  • Python sort List Function
  • Python String Concatenation
  • Python String Length
  • Python substring
  • Python Programming Examples

Copyright © 2021 · All Rights Reserved by Suresh

About Us | Contact Us | Privacy Policy