String Formatting [HackerRank] | Python | rjust() | oct() | hex() | bin()

Pubblicato il: 09 March 2020
sul canale di: Coding Cart
16,430
295

This video is about String Formatting problem from HackerRank.
Problem Statement:
Given an integer, n , print the following values for each integer i from 1 to n:
Decimal
Octal
Hexadecimal (capitalized)
Binary

#HackerRank #String #Python
Problem:
https://www.hackerrank.com/challenges...
Sample code:
def print_formatted(number):
w=len(str(bin(number))[2:])
for i in range(1,number+1):
print(str(i).rjust(w,' '),oct(i)[2:].rjust(w,' '),hex(i)[2:].upper().rjust(w,' '),bin(i)[2:].rjust(w,' '))


For 1 : 1 Tutoring
WhatsApp contact : 7278222619
mail: [email protected]

You can support via UPI : sattujaiswal@okhdfcbank
Follow me on:
whatsapp:
https://chat.whatsapp.com/LNwHGukUizj...

Facebook:
  / sat567  

Linkedin:
  / satyendra-jaiswal-903588a2  

Instagram:
  / jaiswal_satyendra  


In questa pagina del sito puoi guardare il video online String Formatting [HackerRank] | Python | rjust() | oct() | hex() | bin() della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Coding Cart 09 March 2020, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 16,430 volte e gli è piaciuto 295 spettatori. Buona visione!