Create a list from range
list = [x for x in range(5,100,2)] // (begining, end, step)
print(list)
Create a dictionairy from 2 lists
list = [x for x in range(5,20,2)]
listB = ["apple", "banana", "pear"]
dict = {list[i] : listB[i] for i in range(len(listB))}
print(dict) // {5: 'apple', 7: 'banana', 9: 'pear'}
*args and **kwargs
*args passed in a function is treated as a list
def my_sum(*args):
return sum(args)
print(my_sum(1, 2, 3)) // 6
**kwargs passed in a function is treated as a dictionairy
def concatenate(**kwargs):
result = ""
# Iterating over the Python kwargs dictionary
for arg in kwargs.values():
result += arg
return result
print(concatenate(a="Real", b="Python", c="Is", d="Great", e="!"))
// RealPythonIsGreat!
map function
def square(num):
return(num*num)
my_nums = [1,3,5,6]
for number in map(square, my_nums):
print(number) // 1,9,25,36
my_nums = list(map(square,my_nums))
print(my_nums) // [1, 9, 25, 36]
filter function
// return a filtered list of even numbers
def is_even(number):
return number%2 == 0
my_nums = [1,3,5,2,6,12,11]
filtered = list(filter(is_even, my_nums))
print(filtered) // [2,6,12]
lambda functions
my_list = [5,12,33]
print(list(map(lambda num: num **2, my_list))) // [25, 144, 1089]
print(list(filter(lambda num: num%2==0, my_list))) // [12]
Sources: Text Tutorial Espresso Course Main Android Terms An activity is one screen of an app. In that way the activity is very similar to a window in the Windows operating system. The most specific block of the user interface is the activity. An Android app contains activities, meaning one or more screens. Examples: Login screen, sign up screen, and home screen. An activity in Android is a specific combination of XML files and JAVA files. It is basically a container that contains the design as well as coding stuff.
Jun 8, 2023Udemy Course Blog Kotlin features Static Typing: Like Java, variables can only be assigned values that match their type. var m : Int = 12 m = 10 // ok m = "twelve" // error!
May 31, 2023Selenium Architecture
Apr 15, 2023devops docker aws
Sep 26, 2021or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up