5 Random Useful Python Functions

  Рет қаралды 21,628

Indently

Indently

Күн бұрын

Пікірлер: 40
@chyldstudios
@chyldstudios 9 ай бұрын
This video is choice(['cool', 'amazing', 'random'])
@__christopher__
@__christopher__ 9 ай бұрын
Replace choice with sample of size 3
@joshix833
@joshix833 9 ай бұрын
__import__("random").Random(42).choice(("worst", "worse", "bad", "good", "better", "best"))
@nextisnowmain
@nextisnowmain 8 ай бұрын
Amazing ❤
@williamsquires3070
@williamsquires3070 9 ай бұрын
Hint: if you need a list of unique random integers, you combine the list comprehension that generates an ordered list from (x,y), and then call shuffle() on it, where x < y and are integers. 😊
@basurigos
@basurigos 9 ай бұрын
Hey man, your videos are amazing, could you please make a video about how the built in functions work under the hood, like how does __import__ or __build_class__ work, i know those are do not touch functions, but I'm curious
@Russet_Mantle
@Russet_Mantle 7 ай бұрын
7:51 the words you're looking for are "with replacement" (choice) and "without replacement" (sample) as in statistics lingo
@souris_a_boule5695
@souris_a_boule5695 9 ай бұрын
Something that can be interesting is to use the Random class from this module. It provide exact same functions as method but each instance have its own seed and and are not shared with the global seed. So for example you can use this in a class that have random behavior where each instances have their own seed and each random function call will not affect another instance
@danielcrompton7818
@danielcrompton7818 9 ай бұрын
Thank you!😊
@davidmurphy563
@davidmurphy563 9 ай бұрын
Ok, I was into the third function before the penny dropped and I twigged you were covering the `import random` module and not just going through random functions!
@killerfc
@killerfc 9 ай бұрын
🤣 me too
@Indently
@Indently 9 ай бұрын
It was a silly wordplay with the title, I hope you enjoyed the video though! :)
@davidmurphy563
@davidmurphy563 9 ай бұрын
@@Indently Yeah, it was good! I like your vids. Well, I knew it already but, I'm sure many don't and I watch just in case. :)
@danielcrompton7818
@danielcrompton7818 9 ай бұрын
@@Indentlyyes I get the joke now!!
@sovereignlivingsoul
@sovereignlivingsoul 8 ай бұрын
good coding practices, that is what i like to learn, thanks for your input
@dipeshsamrawat7957
@dipeshsamrawat7957 9 ай бұрын
Nice! Keep it up. 💯
@69k_gold
@69k_gold 9 ай бұрын
Does choices() always guarantee that we won't get the element at the same index twice if we call it with a number less than len(list)
@k.r.jester5406
@k.r.jester5406 9 ай бұрын
No, if you want that you should use random.sample()
@yash1152
@yash1152 9 ай бұрын
8:48 shuffle vs sample can trip over many ppl many times ig
@_HetShah_
@_HetShah_ 9 ай бұрын
Do you think there's a way to reverse engineer randomness using seed in some way?
@hindsighttt
@hindsighttt 9 ай бұрын
im pretty sure there is but you gotta look at the code of the random library and do it that way
@DendrocnideMoroides
@DendrocnideMoroides 9 ай бұрын
There definitely is, if you want a more secure version of the random library then use the secrets library in Python.
@katrinabryce
@katrinabryce 9 ай бұрын
Yes, and a lot of security work goes in to making sure people aren't able to do that. Cloudflare for example use a bunch of lava lamps to generate their random seed.
@Reojoker
@Reojoker 9 ай бұрын
Seed is also useful if you write software for research as it allows your results to be easily reproducible.
@paulosergioschlogl9550
@paulosergioschlogl9550 9 ай бұрын
nice video. thanks
@dbottesi
@dbottesi 9 ай бұрын
Another great video!! Thumbs 👍
@danielcrompton7818
@danielcrompton7818 9 ай бұрын
Hey, will you make any more iOS videos, that is actually how I found your channel!!! I also program in Python so your videos are still really interesting
@sadhappy8860
@sadhappy8860 9 ай бұрын
I knew about choices but sample would have been really helpful about a year ago
@Pawlo370
@Pawlo370 9 ай бұрын
how to know seed?
@danielcrompton7818
@danielcrompton7818 9 ай бұрын
Make it up! It doesn’t matter what it is, just so long as it is consistent for the best results
@winTer_x64
@winTer_x64 9 ай бұрын
More flet tutorials plzzz
@michaelhoffmann2891
@michaelhoffmann2891 9 ай бұрын
Addendum: do NOT use any of these for cryptographic, or even scientific, code! 😆
@tinahalder8416
@tinahalder8416 8 ай бұрын
In ML to randomise data, these functions are used. For crypto there is secure module
@alboz1327
@alboz1327 8 ай бұрын
Why wouldn't I use these for sci programming... I can always specify a seed anyway, to make experiments testable. I would be interested if you wanted to give more insights into what you are saying, thanks!
@Lets_code_together_
@Lets_code_together_ 9 ай бұрын
i have applied for coupoun code please provide me it is so much helpful for me
@rishiraj2548
@rishiraj2548 9 ай бұрын
🙏🙂👍
5 Tips To Write Better Python Functions
15:59
Indently
Рет қаралды 114 М.
10 Nooby Mistakes Devs Often Make In Python
24:31
Indently
Рет қаралды 69 М.
REAL or FAKE? #beatbox #tiktok
01:03
BeatboxJCOP
Рет қаралды 18 МЛН
Гениальное изобретение из обычного стаканчика!
00:31
Лютая физика | Олимпиадная физика
Рет қаралды 4,8 МЛН
Mom Hack for Cooking Solo with a Little One! 🍳👶
00:15
5-Minute Crafts HOUSE
Рет қаралды 23 МЛН
Every F-String Trick In Python Explained
19:43
Indently
Рет қаралды 30 М.
5 Really Cool Python Functions
19:58
Indently
Рет қаралды 68 М.
JS Fetch in 3 Minutes
3:30
CodeNexus
Рет қаралды 429
before you code, learn how computers work
7:05
Low Level
Рет қаралды 565 М.
Generate random numbers in Python 🎲
8:03
Bro Code
Рет қаралды 74 М.
10 Neat Ways To Use Underscore In Python
18:17
Indently
Рет қаралды 24 М.
5 Awful Python Mistakes To Avoid
22:13
Indently
Рет қаралды 28 М.
5 Good Python Habits
17:35
Indently
Рет қаралды 666 М.
Python's 5 Worst Features
19:44
Indently
Рет қаралды 113 М.
Python dataclasses will save you HOURS, also featuring attrs
8:50