Jakubication
Jakubication
  • 1 225
  • 319 675
JavaScript forEach vs Map
This video teaches about the array forEach vs map methods in JavaScript. The array forEach method performs a function on each element in an array. Critically, it cannot modify an exisiting array. The array map method on the other hand, performs a function on each element in an array, but can modify elements in the existing array.
Sections
0:00 - Array forEach
0:41 - Array Map
1:18 - Outro
#javascript #codingtutorial #learntocode
Переглядів: 5

Відео

JavaScript Slice vs Splice
Переглядів 112 години тому
This video teaches about the array slice vs splice methods in JavaScript. The array slice method returns a shallow copy of a portion of an array from a starting to ending index. The array splice method changes the contents of an array by removing or replacing existing elements and/or adding new elements. Sections 0:00 - Array Slice 1:42 - Array Splice 2:31 - Outro #javascript #codingtutorial #l...
Python upper vs capitalize
Переглядів 39 годин тому
This video teaches about the upper vs capitalize string methods in Python. upper uppercases all of the characters in a string that can be uppercased. capitalizes, on the other hand only the first letter in a string with a group of words. #python #codingtutorial #learntocode
Python split vs splitlines
Переглядів 6112 годин тому
This video teaches about the split and splitlines string methods in Python. split splits a string into a list, and splitlines splits a string into a list of lines. This video delves deeper into how the methods work practically. #python #codingtutorial #learntocode
Python rsplit vs split
Переглядів 3114 годин тому
This video teaches about the rsplit vs split string methods in Python. rsplit splits a string into a list starting from the right, and split splits a string into a list starting from the left. This video delves deeper into how the methods work practically. #python #codingtutorial #learntocode
Python rfind vs find
Переглядів 516 годин тому
This video teaches about the find vs rfind string methods in Python. find returns the index the substring you are looking for starts at. rfind works similarly to find, although it starts searching from the end of the string, instead of the start of the string. #python #codingtutorial #learntocode
Python partition vs split
Переглядів 9919 годин тому
This video teaches about the partition vs split string methods in Python. partition partitions a string into a certain three element tuple, and split splits a string into a list. This video delves deeper into how the methods work practically. #python #codingtutorial #learntocode
Python isdecimal vs isnumeric
Переглядів 1День тому
Python isdecimal vs isnumeric
Python isdecimal vs isdigit
Переглядів 3День тому
Python isdecimal vs isdigit
Python find vs index
Переглядів 23День тому
Python find vs index
Python casefold vs lower
Переглядів 1314 днів тому
Python casefold vs lower
Python capitalize vs title
Переглядів 714 днів тому
Python capitalize vs title
Creating A Deck Of Cards In Python
Переглядів 1,1 тис.14 днів тому
Creating A Deck Of Cards In Python
Python rstrip vs strip
Переглядів 3014 днів тому
Python rstrip vs strip
Python isdigit vs isnumeric
Переглядів 1414 днів тому
Python isdigit vs isnumeric
Python zip vs enumerate
Переглядів 5521 день тому
Python zip vs enumerate
Python range vs len
Переглядів 1821 день тому
Python range vs len
SyntaxError: parameter without a default follows parameter with a default
Переглядів 421 день тому
SyntaxError: parameter without a default follows parameter with a default
Python isinstance vs issubclass
Переглядів 1321 день тому
Python isinstance vs issubclass
Python filter vs map
Переглядів 1221 день тому
Python filter vs map
Python enumerate vs range
Переглядів 2921 день тому
Python enumerate vs range
SyntaxError: Missing parentheses in call to 'print'
Переглядів 821 день тому
SyntaxError: Missing parentheses in call to 'print'
How to Install Python 3.13.1 on Windows 10/11
Переглядів 36328 днів тому
How to Install Python 3.13.1 on Windows 10/11
error: break outside switch or loop
Переглядів 2728 днів тому
error: break outside switch or loop
Python isinstance vs type
Переглядів 5628 днів тому
Python isinstance vs type
error: continue outside of loop
Переглядів 2428 днів тому
error: continue outside of loop
error: continue statement not within loop
Переглядів 928 днів тому
error: continue statement not within loop
error: break statement not within loop or switch
Переглядів 2428 днів тому
error: break statement not within loop or switch
SyntaxError: Illegal break statement | JavaScript Errors
Переглядів 528 днів тому
SyntaxError: Illegal break statement | JavaScript Errors
SyntaxError: Illegal continue statement: no surrounding iteration statement | JavaScript Errors
Переглядів 628 днів тому
SyntaxError: Illegal continue statement: no surrounding iteration statement | JavaScript Errors

КОМЕНТАРІ

  • @thrasosthrasos7353
    @thrasosthrasos7353 2 дні тому

    Example #3: it is not True that split of string with bunch of spaces gives 'h' and 'i' for each doubled space an empty string will be generated.

    • @jakubication
      @jakubication 2 дні тому

      I ran the following code in Python and it generated just the list: ["h","i"]. print("h i".split()). So it looks like on this matter that you are mistaken.

    • @thrasosthrasos7353
      @thrasosthrasos7353 День тому

      @@jakubication yes, you're right when f-on split() has no arguments, but when separator argument is specified empty strings are generated (which is not intuitive at all). print("h i".split(" ")) generates ["h", "", "i"]

  • @AcceptableDatabase0528
    @AcceptableDatabase0528 5 днів тому

    thank you

  • @erosnemesis
    @erosnemesis 5 днів тому

    No .ToSting method...must be a crappy language.

    • @jakubication
      @jakubication 5 днів тому

      Lol, you're not wrong

    • @sevret313
      @sevret313 4 дні тому

      Because a small d double is not an object and only objects can have methods.

    • @erosnemesis
      @erosnemesis 4 дні тому

      @@sevret313 all types, including concrete types, are derived from an Object.

    • @sevret313
      @sevret313 4 дні тому

      @@erosnemesis No, primitive types in Java are not derived from Object.

    • @erosnemesis
      @erosnemesis 4 дні тому

      @@sevret313 true but you could always use Double or Integer instead

  • @MicahMCgonical
    @MicahMCgonical 5 днів тому

    Thanks

  • @darknight3613
    @darknight3613 9 днів тому

    Heres an idea for your next upload: How to increment an integer by 1? int x = 1; x++;

    • @jakubication
      @jakubication 9 днів тому

      You joke, but this video is a part of a larger strategy to make sure my shorts are evergreen. No matter how simple the concept is, people in a regular consistent pattern search "how to convert double to float in Java'', on UA-cam. As people are searching that topic, my video comes up and I get consistent views

    • @darknight3613
      @darknight3613 9 днів тому

      @jakubication maybe people would search how to increment an integer by 1, You should make a short about it too

  • @hurzely
    @hurzely 12 днів тому

    now u got a long d... nice I would love to have double d s tho so idk if I would cast that

  • @akruijff
    @akruijff 12 днів тому

    You do not need the explicit cast.

    • @jakubication
      @jakubication 12 днів тому

      I just ran the code again, and it looks like you DO need the explicit cast. Omitting the explicit cast gives the possible lossy... error when you go to compile/run the code

    • @akruijff
      @akruijff 12 днів тому

      @jakubication Thanks for the feedback. A search on Google tells me implicit cast in Java are only allowed if there is no information loss.

  • @notnilc2107
    @notnilc2107 12 днів тому

    can you show us how to add 2 and 2?

  • @DaveLeCompte
    @DaveLeCompte 13 днів тому

    @3:33 probably want to do rank and suit for the __str__ method. I was expecting you to go back and show the print card test you had done earlier, showing the __str__ method doing its job. Other suggestions: - if I'm extracting a single card from the deck, I'd call that "draw" - "deal" suggests to me an entire process of a hand to each player, so maybe deal would take in a hand_size and player_count, and deal out a list of cards for each player. - if we're extracting cards from the deck (with deal or draw or some other method), there probably ought to be a way to insert cards back into the deck when you're done with the hand. In some games, it's fine to "burn" the entire deck and start with a new deck, shuffled randomly, but I wouldn't presume this. - similarly, I'd leave the decision to shuffle the deck to the user of the class - when I buy a pristine deck of cards, it comes in a sorted order, and I think this is fine for our Deck class. If the user wants it shuffled, that's easy.

    • @jakubication
      @jakubication 13 днів тому

      Yeah, you're right on that first part. That was simply a mistake I didn't catch in editing the video. As for you other suggestions, I would tend to agree. I'm pretty sure in making this video I had the implicit assumption that I could extend this code/video later for Blackjack. And that's how I made most of my design decisions. So: 1) Shuffling would be important within the deck class because unshuffled decks in blackjack would make an easy system to game, 2) There wouldn't be any concept of putting cards back in the deck, 3) Dealing would work fine because you would deal for the player and the dealer/house. Of course the calc_value logic would have to modified and the __str__ method would have to be fixed, but the rest would be easy to use in a game of blackjack.

  • @adamkormendi5904
    @adamkormendi5904 13 днів тому

    The __init__() is the initializer, not a constructor. I wonder if this actually works. The calc_value() method should have been defined as a static method, otherwise the "rank" will be self, actually. Also I would still use letters for the suits, and use the __str__() method to do pretty print. The "ranks" and "suits" would also be class variables in my book.

    • @jakubication
      @jakubication 13 днів тому

      I never actually knew that first part about constructor vs initializer. Thanks for the knowledge. I'm not certain on this, but I think because I called calc_value as a class method (using the name of the class, Card), that is why everything works as intended. Reasonable people can disagree on what to use/do for the suits. Finally, no disrespect, I see no world where ranks and suits would make sense as class variables. If you're having to "initialize" each card with __init__, shouldn't eàch card have instance variables? Or are you saying at the deck level it should have 52 class variables that each have a rank and suit? Ultimately I made the decisions I made in this video because I want to appeal to a beginner level audience. If I use time in the video to pontificate on constructor vs initializer, or introducing a new (to the viewer) kind of method like a static method, then I feel strongly like I'm disrespecting the viewer's intelligence and time. The aim of the video is just create a deck of cards in Python, so I try my best to avoid getting into the weeds.

    • @adamkormendi5904
      @adamkormendi5904 11 днів тому

      @@jakubication You know it is an initializer, because it has "self" as parameter. So "self" should already been created, we are just giving values here. "that is why everything works as intended" I have tried, indeed it does work. But I would have added @staticmethod on top of the calc function and use "self" instead of Card. Because if you create an instance of the Card, - e.g. c = Card() - then calling c.calc_value() would throw an error. "I see no world where ranks and suits would make sense as class variables." I wrote "suits" not suits, because I meant the array you use to generate the deck and not a specific suit value. They could be class variables, so they can be queried from outside of the class as Deck.suits. Also "ranks" could be a dictionary, so that you can add a value to each, no need for a method to do that

  • @roblox_noob12491
    @roblox_noob12491 13 днів тому

    straight forward and w, thanks

  • @bilbilzabeli3828
    @bilbilzabeli3828 13 днів тому

    I am not a Python developer, but I think you could also use the ranks array index + 1 to get the rank value...

    • @jakubication
      @jakubication 13 днів тому

      That may very well work, but I was always taught to make sure my code was easy to read/made sense/was intuitive. Just because the array indicies of the rank's happen to correlate to the value of the card, doesn't mean I should use that. But I do understand what you're saying, thanks for the suggestion.

    • @DaveLeCompte
      @DaveLeCompte 13 днів тому

      That works for several of the cards in this case, but 10, J, Q all have value 10 and K has value 0 for the expected use case here, so you still need to special case those. For me, I'd probably put the rank to value computation in game logic, outside of the deck logic, which would make the deck and card classes reusable for many different games.

  • @codewizard01
    @codewizard01 14 днів тому

    What IDE theme you are using?

  • @moktatafatforyou-2378
    @moktatafatforyou-2378 15 днів тому

    Great example for practicing oop in python, thank you ❤

    • @jakubication
      @jakubication 15 днів тому

      You're welcome! Glad you liked it 👍

  • @ireonus
    @ireonus 15 днів тому

    In line 6 , why do you create another Card class within the Card constructor method , does that not create an infinite loop ? Also I feel to import a method to shuffle a list is cheating ? It could be better if you wrote your own function to shuffle it , maybe split the deck into n decks then merge them in alternating order m amount of times to mimic the riffle shuffle , it does not matter as long as your shuffle function is your own! Just giving the thumbs up for taking the time and courage to create it !

    • @jakubication
      @jakubication 15 днів тому

      For you first point, I believe you're talking about the line, self.value = Card.calc_value(self.rank). That wouldn't create an infinite loop. It's written that way because, calc_value is a class method (belongs to the card class, not a particular card instance) so I couldn't call self.calc_value, so the only other option is to call Card.calc_value. And as for the shuffling method, I was always taught in college CS classes 3 main things, don't implement your own code to handle money (floating point imprecision), don't write your own cryptography code (someone smarter than you will surely crack it almost instantly), and don't write your own code to generate random values. (I don't remember the why for this one but presumably the answer is if this were apart of a serious gambling game at a casino, and you're randomness functionality was easily understood, then it's basically an easy money glitch). So that's my reason for that. Basically, if it's not the main part of the project I'm working on (the deck of cards and the cards themselves surely are the more important part then the cards being shuffled), then if someone has already written code for me to easily do a thing, then why reinvent the wheel. Hopefully that explains it. Thank you for the kind words at the end of your comment as well

    • @DaveLeCompte
      @DaveLeCompte 13 днів тому

      > to import a method to shuffle a list is cheating ? random.shuffle() exists for exactly this reason. If you want to flex and write your own, you certainly can, and if it's fun, or if you're asked to for a programming interview, then sure. But for most use cases, the standard implementation is as good and better than one's own implementation. The OP gives 3 examples of when to not write your own implementation, but if the standard implementation works, then don't repeat the effort.

  • @JoeJacksonMhmm
    @JoeJacksonMhmm 16 днів тому

    interesting

  • @DraxSplash
    @DraxSplash 21 день тому

    gracias, chaval

  • @VanshYadav-y9m
    @VanshYadav-y9m 21 день тому

    Nice sir thanks

  • @manwiththelowend-yb7md
    @manwiththelowend-yb7md 22 дні тому

    They're not really comparable. IFs are for taking action given the logical result of a condition evaluation. TRY/EXCEPT are for responding to code that could fail, such as trying to open a file, and giving the program a chance to recover from the failure, not crash, present an error and potentially try an alternative command

    • @jakubication
      @jakubication 22 дні тому

      I understand what you're saying and agree. My purpose in making the video wasn't necessarily that the two are comparable, just fulfillment of keyword research. Apparently people consistently search "Python if vs try", so I made this where I explain if, then try in a concise manner.

  • @FightStreeting
    @FightStreeting 22 дні тому

    lol

  • @CH_CODE
    @CH_CODE 24 дні тому

    wau... I loved

  • @nitram0410
    @nitram0410 25 днів тому

    sudo rm -rf /

    • @nitram0410
      @nitram0410 25 днів тому

      Good video btw

    • @jakubication
      @jakubication 25 днів тому

      Thanks 👍 I always appreciate a kind viewer

  • @Something-55
    @Something-55 25 днів тому

    I don’t know python but from a quick internet search where all the responses say that pass does nothing. It is my opinion that pass is a vital part of the python language due to the absence of begin/end blocks.

    • @jakubication
      @jakubication 25 днів тому

      Yeah, you have to fudge the full reality a bit in a UA-cam short. pass definitely works as a placeholder that you can come back around later and fill in. But, strictly speaking, it doesn't evaluate to a value, and it doesn't change any state. Ultimately I would say it's up to the individual and how they would define "doing nothing" in code.

  • @BloomerMindset
    @BloomerMindset 25 днів тому

    Yesh but what does this have to do with snakes?

    • @jakubication
      @jakubication 25 днів тому

      Um, assuming this isn't sarcasm, Python is the name of the programming language from which I'm teaching the concepts in the video. It has nothing to do with snakes.

    • @BloomerMindset
      @BloomerMindset 25 днів тому

      @jakubication program like choir programs? And language like you can speak it to other people? This is blowing my mind rn

    • @jakubication
      @jakubication 25 днів тому

      Program like a set of instructions to make a computer do something. Language like a certain well-defined type of instructions to make a computer do something. Here's the first paragraph from the Wikipedia article for further reading: "A programming language is a system of notation for writing computer programs.[1] Programming languages are described in terms of their syntax (form) and semantics (meaning), usually defined by a formal language. Languages usually provide features such as a type system, variables, and mechanisms for error handling. An implementation of a programming language is required in order to execute programs, namely an interpreter or a compiler. An interpreter directly executes the source code, while a compiler produces an executable program."

    • @BloomerMindset
      @BloomerMindset 25 днів тому

      @@jakubication oh like Minecraft

  • @tatybara
    @tatybara 27 днів тому

    i love how to the point this was

  • @DavidKing-wk1ws
    @DavidKing-wk1ws 27 днів тому

    Can I get a byte of that :)

  • @xfaon
    @xfaon 27 днів тому

    What the mental gymnastics

  • @pwssv67
    @pwssv67 28 днів тому

    Underrated video

  • @СулейманДадаев-ъ5л

    How

    • @jakubication
      @jakubication 28 днів тому

      Although they look identical, because the two objects don't occupy the same memory address, JavaScript says they do not equal each other.

  • @jakubication
    @jakubication 29 днів тому

    *break* can also occur inside switch statements legally. All else in the video is correct, though.

  • @beercansam2304
    @beercansam2304 Місяць тому

    Very interesting short to get out of nowhere

  • @mryesilyurt1
    @mryesilyurt1 Місяць тому

    24

  • @doyouknow-t1m
    @doyouknow-t1m Місяць тому

    thx

  • @arunasimas
    @arunasimas Місяць тому

    Or Arrays.stream(arr).collect(Collectors.toList())

    • @jakubication
      @jakubication Місяць тому

      That works. Ultimately it's a balancing act between readability and conciseness

  • @NicusorN5
    @NicusorN5 Місяць тому

    No, atleast this is not the best idea. This is an implicit cast. The same effect as d = (double)i (this is a c-style) cast. There's static_cast<T>, C-style casts, type punning using reinterpret_cast<T>, bit_cast, or using a memcpy call. const_cast<T> is almost always UB and should never be used. C style casts can have the same effect as a static cast combined with a const_cast. For C++ you'll want to use d = static_cast<double>(i); .

  • @salahabdinoor5656
    @salahabdinoor5656 Місяць тому

    How do you do it in Java?

    • @jakubication
      @jakubication Місяць тому

      Very similar to this, but you cast the double to an int on the same line you assign it to an int. I can't link to videos in comments because this is a short, but if you search "How To Convert Double Int In Java Jakubication", I have a video on this that will show you the code for how to do it. Cheers!

    • @salahabdinoor5656
      @salahabdinoor5656 20 днів тому

      @@jakubication Found the video! It was very helpful! Thank you very much for your hard work :D

  • @danielcastillo-vl1rc
    @danielcastillo-vl1rc Місяць тому

    This was great content, keep it up👍

  • @LivingDoorknob
    @LivingDoorknob Місяць тому

    .. Cant you cast the integer?

    • @AirLiftingMonkeys
      @AirLiftingMonkeys Місяць тому

      Also that

    • @jakubication
      @jakubication Місяць тому

      Yes, but that wouldn't fit on the screen when trying to record the short. In real life code, though, it's just a matter of whether or not you prefer explicit (doing the cast) being better than implicit (what this code does).

  • @TheDataworm
    @TheDataworm Місяць тому

    right to the point, thanks

  • @MaxWalker.1989
    @MaxWalker.1989 Місяць тому

    Thanks for this im glad the algorithm put this on my screen today as im learning python and Linux im subscribing to as many tutorials as i can My pc im building ready to start learning is nearly ready i cant wait

  • @AndrewLuhring
    @AndrewLuhring Місяць тому

    lol

    • @AndrewLuhring
      @AndrewLuhring Місяць тому

      no idea why this made me actually laugh out loud but it did

    • @jakubication
      @jakubication Місяць тому

      I always appreciate a viewer

    • @AndrewLuhring
      @AndrewLuhring Місяць тому

      @@jakubication please make more like this. want to write a function in c++? just write a function. this rules.

  • @adityamwagh
    @adityamwagh Місяць тому

    No. You should use std::static_cast<> and make it explicit. We write code for other programmers to understand.

    • @jakubication
      @jakubication Місяць тому

      Genuinely didn't even know std::static_cast<> was a thing. Thanks for the pointer 👍

  • @ANSOLOW
    @ANSOLOW Місяць тому

    thanks

  • @AyanTanvir
    @AyanTanvir Місяць тому

    In simple terms elif = else if

  • @El3ziiiz
    @El3ziiiz Місяць тому

    thank u

  • @beebait1464
    @beebait1464 Місяць тому

    Sick, I don't know how this ended up on my feed, but seeing as Im learning java its nice to know

    • @jakubication
      @jakubication Місяць тому

      If you didn't already know, Java and JavaScript are very different languages. But, the concept of NaN (not a number) not being equal to anything applies across Java, JavaScript, and most other (if not all) languages

  • @miroslavchytka3528
    @miroslavchytka3528 Місяць тому

    break is used to exit loops return is used to exit functions exit() is used to terminate the program But cool video man ;) keep it up

    • @jakubication
      @jakubication Місяць тому

      Thanks for the kind words. Yeah, I pinned a comment that pointed out my mistake

  • @elokthewizard
    @elokthewizard Місяць тому

    doesn’t exit actually terminate a program?and return is used to exit functions?

    • @jakubication
      @jakubication Місяць тому

      You're right, I got that wrong in the video