unlimited arguments python
def add(*args): # *args takes multiple inputs
return sum(args)
print(add(1,2,3,4,5)) # prints 15
print(add(10, 20, 30)) # prints 60
unlimited arguments python
def add(*args): # *args takes multiple inputs
return sum(args)
print(add(1,2,3,4,5)) # prints 15
print(add(10, 20, 30)) # prints 60
mulitplication symbo for unpacking in python
>>> numbers = [2, 1, 3, 4, 7]
>>> more_numbers = [*numbers, 11, 18]
>>> print(*more_numbers, sep=', ')
2, 1, 3, 4, 7, 11, 18
or in python
# Syntax for Boolean expression with or in Python
exp1 or exp2
* in python
>>> fruits = ['lemon', 'pear', 'watermelon', 'tomato']
>>> print(fruits[0], fruits[1], fruits[2], fruits[3])
lemon pear watermelon tomato
>>> print(*fruits)
lemon pear watermelon tomato
** in python
#** is the exponent symbol in Python, so:
print(2 ** 3)
#output: 8
! in python
#The (!) is the not operator in Python, (!=) means not equal to.
if 2!=10:
print("2 isn't equal to 10.")
elif 2=10:
print("2 is equal to 10.")
#Prints "2 isn't equal to 10." as 2 isn't equal to 10. Is it?
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us