WHAT!? You Can Do THIS In Python?

Hacking Truth
0

 

WHAT!? You Can Do THIS In Python?

 

WHAT!? You Can Do THIS In Python?! 


  • Python is a general purpose programming language that is often applied in scripting roles.
  • So, Python is programming language as well as scripting language.
  • Python is also called as Interpreted language 
  • Python is an experiment in how much freedom programmers need.
  • Too much freedom and nobody can read another's code; too little and expressiveness is endangered. 

 

 

so right here we went ahead and defined a variable called banana and now let's go ahead and print it using the asterisk if you go ahead and run this it's going to print them all as separate elements.


var: str = 'Banana'

print(*var)



WHAT!? You Can Do THIS In Python?

 

 

and one cool thing you can do with this is add a separator and add some sort of symbol and it's going to create this funky text.



var: str = 'Banana'

print(*var, sep='.')




 

WHAT!? You Can Do THIS In Python?

 

 

now what you witnessed here is an unpacking operator which means if you were to create a list with the unpacking operator and you were to go ahead and print this list you'd get a list back for eachletter in banana.




var: str = 'Banana'
list_: list[str] = [*var]

print(list_)





WHAT!? You Can Do THIS In Python?



Also Read - The python Logic

Also Read - Never do this in Python


 

this can be quite useful if you have some arguments that you want to pass in as a tuple into a function
so for example we have a and b here that we want to pass into this function here and when we actually go ahead and call this it's going to take these two variables it's going to unpack them and put them inside A and B and we're going to be able to use that function with these arguments.





args: tuple = (1, 'a')

def func(a, b):
    print(a, b)


func(*args)




 

WHAT!? You Can Do THIS In Python?

 

 

 

Disclaimer

All tutorials are for informational and educational purposes only and have been made using our own routers, servers, websites and other vulnerable free resources. we do not contain any illegal activity. We believe that ethical hacking, information security and cyber security should be familiar subjects to anyone using digital information and computers. Hacking Truth is against misuse of the information and we strongly suggest against it. Please regard the word hacking as ethical hacking or penetration testing every time this word is used. We do not promote, encourage, support or excite any illegal activity or hacking.
 
 


Tags

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.
Post a Comment (0)
Our website uses cookies to enhance your experience. Learn More
Accept !