[Python Programming Basics to Advanced]: Number Formatting and Number Systems | Lab 04 P-1

preview_player
Показать описание
This Python programming playlist is designed to take beginners with zero programming experience to an expert level. The course covers installation, basic syntax, practical scenarios, and efficient logic building. The course material includes PDF handouts, review questions, and covers a wide range of topics, from data types to advanced functions like Lambda and Recursive functions, Generators, and JSON data parsing.

In this lesson we will study about formatters we can use with fstrings. These formatters are specially helpful for numbers for example:
1- Thousand Separators for better readability of large numbers.
2- Percentage Formatters.
3- Sign Formatters
4- Rounding-off numbers
5- Left Alignment, Right Alignment and Centre Alignment.
6- Right Padding, Left Padding

Complete Playlist:

If you have the basic programming knowledge and interested to learn Object-Oriented Programming in Python, check out this playlist:

Lab Manual 04 can be downloaded from here:

Review Questions:
1- Take a decimal number from user from 0-255 (Assume that user will enter in this range) and display that number in Decimal, Binary, Octal and Hexadecimal Format on different lines. Additionally, you are allowed to use just one print statement for all display lines.

#PythonProgramming #python #pythontutorial
Рекомендации по теме
Комментарии
Автор

a=eval(input('Enter any number between 0 to 255:'))
print(f'In decimal form:{a}'+f'\nIn binary form:{a:0b}'+f'\nIn octal form:{a:0o}'+f'\nIn hexadecimal form:{a:0x}')

wasifalii
Автор

y = int(input("Enter a decimal number in range 0-255:"))
print(f'In decimal format:{y:0d}\nIn binary format:{y:0b}\nIn octal format:{y:0o}\nIn hexadecimal format:{y:0x}')

hamidiftikhar
Автор

y=eval(input('Enter the decimal number from 0-255:'))
Print(f'Decimal format is :{0:0d}, f'\n Binary format is :{y:0b}, f'\n octal format is :{y:0o}, f'\n Hexadecimal format is :{y:0x},

MuhammadHassan-ldyt
Автор

x=eval(input("Enter a number from 0-225:"))
print(f'In decimal form:{x:0d}'+f'\nIn binary form:{x:0b}'+f'\nIn octal form:{x:0o}'+f'\nIn hexadecimal form:{x:0X}' )

asmaabhatti
Автор

H=eval(input("Enter a number in the range 0-255: "))
print(f" number in decimal format is:{H:0d} \n Number in Binary Format is: {H:0b} \n Number in Octal Form is:{H:0o} \n Number in Hexa Decimal Format is:{H:0x}")

haseebahmad
Автор

X=eval(input("enter a decimal number in range 0-255:"))
print(f'decimal form:{x:0d}'+f'\n binary form:{x:0b}'+f'\n octal form:{x:0o}'+f'\n hexadecimal form:{x:0X}')

AliIrfan-soxf
Автор

x=eval(input('Enter a number in range of 0-255:'))
print(f'Decimal form {x:0d}'+f'\n Binary form{x:0b}'+f'\n Octal form: {x:0o}'+f'\n Hexadecimal form {x:0x}')

zainulhassan
Автор

b=eval(input('Enter a decimal number from 0-255: '))
print(f'In decimal:{b:0d}\nIn binary:{b:0b}\nIn octal:{b:0o}\nIn hexadecimal:{b:0X}')

habibaasif
Автор

x=eval(input('Enter any decimal number in between 0-255='))
print(f'In decimal:{x:0d}\nIn binary:{x:0b}\nIn octal:{x:0o}\nIn hexadecimal:{x:0x}')

SafiUllah-kgku
Автор

x=eval(input('Enter a decimal number in the range of (0-255): '))
print(f'In decimal form: {x:0d}'+'\n'f'In binary form: {x:0b}'+'\n'f'In octal form: {x:0o}'+'\n'f'In hexadecimal form: {x:0X}')

usman_tariq
Автор

x=eval(input("Enter a number in range of 0-255: "))

print(f'Decimal format is: {x:0d}', f'\nBinary format is: {x:0b}', f'\nOctal format is: {x:0o}', f'\nHexadecimal format is: {x:0x}')

waleedraza
Автор

x=eval(input('Enter a Decimal Number from o-255:'))
print(f' In Decimal format : {x:0d}', f'\nBinary format is: {x:0b}', f'\nOctal format is: {x:0o}', f'\nHexadecimal format is: {x:0x}')

dawood
Автор

x=eval(input("Enter a number(0 to 255): "))
print(f"\nIn Decimal form: {x:0d}\nIn Bianry form: {x:0b}\nIn Octal form: {x:0o}\nIn Hexa-Decimal form: {x:0X}")

abdurrehmansarwar
Автор

x=eval(input("Enter a decimal number from 0-255: "))

print(f"In decimal:{x:0d}\nIn binary:{x:0b}\nIn octal:{x:0o}\nIn hexadecimal:{x:0X}")

technicalnfit
Автор

a=eval(input("Enter a Decimal Number from 0-255:"))
print(f"In Decimal: {a:0d} \nIn Binary: {a:0b} \nIn Octal: {a:0o} \nIn Hexadecimal: {a:0X}")

fourcloversan
Автор

x=eval(input("Enter a number in the range of (0-255):"))
print(f'Decimal Form:{x:0d}'+f'\nBinary Form:{x:0b}'+f'\nOctal Form:{x:0o}'+f'\nHexadecimal Form:{x:0X}')

MuhammadQasim-erwb
Автор

z=eval(input("Enter a number in the range of (0-255):"))
print(f"In Decimal form:{z:0d}"+f"\nIn Binary form:{z:0b}"+f"\nIn Octal form:{z:0o}"+f"\nIn Hexadecimal form:{z:0Z}")

haris
Автор

x=eval(input("Enter a no in range of 0-255: "))
print(f" No in decimal format is: {x:0d}\n No in Binary format is: {x:0b}\n No in Octal format is: {x:0o}\n No in Hexadecimal format is: {x:0x}")

maeshaijaz
Автор

r=eval(input("Enter a decimal number from 0-255:"))
print(f'Decimal Format:{r:0d}\nBinary Format:{r:0b}\nOctal Format:{x:0o}\nHexadecimal Format:{r:0x}')

areebaazhar
Автор

z=eval(input("Enter number in range 0-255")
print (f"Decimal form is:{z:0d}\nOctal form is:{z:0o}\nHexadecimal form is:{z:0x}\nBinary form is:{z:0b}")

irsaidress
welcome to shbcf.ru