Post Series: Part 1: Hello world and Basic Data Types
Part 2: Array, Collection and Range
Part 3: Control Flow
Part 4: Function
Part 5: Class
Merry Christmas Guys! The year 2018 is about to end. This have been a great year. Happy New Year 2019, May your new year be filled with Joy and Happiness. This will probably be the last post for this year 2018. Hope to see you all in the next year!
Post Series:
Part 1: Hello world and Basic Data Types
Part 2: Array, Collection and Range
Part 3: Control Flow
Part 4: Function
Part 5: Class
In this post we are going to learn about the control flow in Kotlin. Let us learn about how to make a decision, how to perform a task multiple times by iterating and how to get out of the loop, how to continue to next iteration.
Post Series:
Part 1: Hello world and Basic Data Types
Part 2: Array, Collection and Range
Part 3: Control Flow
Part 4: Function
Part 5: Class
In this post we will discuss about the Array, Collection and Range in Kotlin.
Array In Kotlin, we can create array using two different ways. First one is by using arrayOf() function and next one is by using Array() constructor.
Using arrayOf() function val accountInfo = arrayOf("Sudeep", 34000) The accountInfo array is of type Array<Any>.
Post Series:
Part 1: Hello world and Basic Data Types
Part 2: Array, Collection and Range
Part 3: Control Flow
Part 4: Function
Part 5: Class
Since Kotlin is already a official programming language for Android Apps development, I have been learning Kotlin lately. In this post, i will take you through basic hello world skeleton program to data types, variables in Kotlin.
Hello World Program for Kotlin fun main(args: Array) { println("Hello World!
Today the wind blows in my room through my window making sound with my curtains forced me to write something on itself.
चन्द्रको उज्यालोको सितलता बुझ्न सके
उढेर चन्द्रमा छुन किन पर्थ्यो र?
हावाको झोकाको इस्पर्स बुझ्न सके
बियोग को पिडामा तिमिलाइ सम्झी रातभर छटपत्याउन किन पर्थ्यो र?
गज्रिदै बगेको खोलाको चट्टानको र चत्याङ्ग पर्दा को पहाडको मौनता बुझ्न सके
शान्ति खोज्दै एकान्तमा बस्न किन पर्थ्यो र?
Python Developer’s Meetup Nepal #13 Question Solution
Q: Write a python script that recursively walks all sub-directories and searches all files with extension *.png or *.PNG and append them to the list.
Solution:
import os # list variable to store the .png and .PNG file png_file_list = [] # Recursive function to traverse all the sub-dirctory and check for png files def traverse_directory(dir_path): for child in os.listdir(dir_path): path = os.path.join(dir_path, child) if os.
ब्याचलर भ्याएको लगभग १ वर्ष बितिसकेको थियो, म केहि काम परेर फेरी आफुले पढेको कलेज गएको थिए| म तेहा पुगेपछि आफुलाई पडाएको गुरु देखे र नमस्कार गरे| अनि उहाले के गर्दै छौ, के कस्तो छ भन्नु भयो| कुरा चल्दै गयो र पछि उहाले मलाई सोध्नुभयो बाबु तिम्लाई के को दुखः छ र? मैले उहालाई सोधे “किन र सर? तेस्तो त केहि छैन”|
यो प्रश्न मलाई चिन्तित देखेर अथवा कुनै कारण ले सोधिएको थिएन| म एस प्रश्नले खासै चकित पनि थिइन किनकि मैले अद्यात्म तिर लागेर फसेबूकमा ध्यान गरेको, तेस्तै कार्यक्रममा सहभागी भएको र अद्यात्म सम्बन्धित पोस्टहरु गरेको देखेर मलाई हिजो आज धेरै ले एस्तो खाल्को कुरा भन्नु हुन्न्छ, मलाई बडो अचम्म लाग्छ|
(सेतोपाती मा प्रकाशित) प्रकाशित मिति: मङ्गलबार, मंसिर १२, २०७४ ०९:२१:१२
मंसिर महिनाको ८ गतेको दिन थियो, दिन भर ल्यापटपमा काम गरे पछि बेलुका ५ बजे तिर सरिर तन्काउन पर्यो भनेर म होस्टेल बाट निस्किए| म पुतलीसडक बाट बागबजार हुदै घण्टा घर भएर जादै थिए, बाटोमा माछापुछ्रे बैंकको ATM देखे | तेस पछि मैले होस्टेलमा तिर्ने पैसा निकाल्ने निर्णय गरे|
त्यो बेलामा होस्टेल मा महिनाको ११ हजार रुपैया तिर्नु पर्ने थियो| आम्दानी खासै न भएकोले गर्दा यो धेरै ठुलो रकम थियो, तेस माथिपनि आफैले दुख गरेर कमाएको पैसा ATM बाट स्वात्तै घटेको देख्दा मन चसक्क हुदो रहेछ|
{- Convert positive integer to list of digit -} {- Input : 12345 o/p : [1, 2, 3, 4, 5 -} toList :: Integer -> [Integer] toList 0 = [] toList x = toList (x `div` 10) ++ [x `mod` 10] {- Reverse the integer after converting it to list -} -- toDigitsRev :: Integer -> [Integer] toListReverse :: Integer -> [Integer] toListReverse xs = (reverse . toList) xs {- Double every second number -} doubleSecondEach :: [Integer] -> [Integer] doubleSecondEach [] = [] doubleSecondEach (x:[]) = [x] doubleSecondEach (x:y:xs) = x : (2*y) : doubleSecondEach xs {- Sum the digit in the number we are sure there is one digit number or two digit number -} sum' :: Integer -> Integer sum' x = (x `mod` 10) + (x `div` 10) {- sum all the element in list -} {- when a element is [13,5,6] we have to add like this: 1 + 3 + 5 + 6 -} sumDigits :: [Integer] -> Integer sumDigits [] = 0 sumDigits [x] = sum' x sumDigits (x:xs) = sum' x + sumDigits xs {- Validate the credit card number -} validate :: Integer -> Bool validate x = if (sumDigits $ doubleSecondEach $ toListReverse x ) `mod` 10 == 0 then True else False
The time flows like a river, it is certain that it won’t wait and we can not travel back in time. The yesterday is history so we can not change it. In spite of not being able to change the history, we should analyze it and learn from it piece by piece. Today, me running at the age of 25 i feel that i have missed many opportunities because of not taking a simple step that would require for the great beginning.