Skip to content

Commit

Permalink
Assert & list Comprehension has been explained.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ajay2521 authored Aug 15, 2020
1 parent 7be0ad5 commit 42e98c0
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
25 changes: 25 additions & 0 deletions ADVANCE/Assert & list Comprehension/Assert.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# In this lets see about the assert in the python.

# Assert is a kwyword used to define a debugging tool which is used to test a condition.

# If the condition is true then it moves to the next line.

# If the condition becomes false then it will be resulting in an AssertionError.

# Syntac for assert is:

# assert condition,error_message

# condition = Condition to be checked.

# error_message = error message to be displayed , which is optional.

# Here is the example for assert

a = int(input('\nEnter value of "a" : '))

b = int(input('\nEnter value of "b" : '))

assert b != 0,'Divisor 0 error'

print('\na / b is : ',a/b)
17 changes: 17 additions & 0 deletions ADVANCE/Assert & list Comprehension/list comprehension.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# In this list comprehension has been explained.

# List Comprehension is defined as an elegant way to define.

# The list comprehension starts with '[' and ']'.

# [ expression for item in list if conditional ]

# Here is the program for list comprehension.

List = [data for data in range(1,11)]

print() # empty line for readability.

print(List)

print() # empty line for readability.

0 comments on commit 42e98c0

Please sign in to comment.