H

Hafeezul Kareem

I am a Pythoneer currently studying 3rd year in my Computer Science course. I will be a computer science graduate in 2 years. I am very fond of Python and Programming. I love to learn new technologies and enthusiastic about sharing my knowledge across the programming community.

4 posts

Posts by Hafeezul Kareem

This article shows you how to write Python ternary operator, also called conditional expressions. <expression1> if <condition> else <expression2> expression1 will be evaluated if the condition is true, otherwise expression2 will be evaluated. 1. Ternary Operator 1.1 This example will print whether a number is odd or even. n = 5 print("Even") if n % […]

Read more Python Ternary Conditional Operator

In Python, we can use index -1 to get the last element of a list. #!/usr/bin/python nums = [1, 2, 3, 4, 5] print(nums[-1]) print(nums[-2]) print(nums[-3]) print(nums[-4]) print(nums[-5]) print(nums[0]) print(nums[1]) print(nums[2]) print(nums[3]) print(nums[4]) Output 5 4 3 2 1 1 2 3 4 5 Yet another example. #!/usr/bin/python # getting list of nums from the […]

Read more Python – Get the last element of a list