How to Get Category ID in WordPress Category Page

In file category.php file, you can get category id very easily. Look at code below:

<?php
$category = get_category(get_query_var('cat'));
$cat_id = $category->cat_ID;
print_r($category);
?>

The result is:

WP_Term Object
(
    [term_id] => 2
    [name] => NumPy
    [slug] => numpy
    [term_group] => 0
    [term_taxonomy_id] => 2
    [taxonomy] => category
    [description] => 
    [parent] => 0
    [count] => 0
    [filter] => raw
    [cat_ID] => 2
    [category_count] => 0
    [category_description] => 
    [cat_name] => NumPy
    [category_nicename] => numpy
    [category_parent] => 0
)

,