当前位置:网站首页>Data type conversion and conditional control statements

Data type conversion and conditional control statements

2022-06-12 13:39:00 Faith, faith

1. Data type conversion :
  Will float , String to integer

Convert floating point to integer :

String to integer :


  The integer , String to floating point

Integer to floating point :

 

String to floating point :


  Binary , octal ,16 Base to 10 Base number

print(int(0b100))
print(int(0o100))
print(int(0x100))
 result :4
     64
     256


  take 10 Base to zero , Binary system , octal ,16 Base number

print(bin(4))
print(oct(64))
print(hex(256))
 result :0b100
     0o100
     0x100


  Convert string to byte


  Convert bytes to strings

 

 


  take ascii Code to string

print(chr(97))
 result :a


  Converts a string to ascii code

print(ord('a'))
 result :97


2. Conditional control statements
  A: 86-100, B: 71-85, C: 61-70, D: 0-60
  Enter a grade and print out the grade ( Required if ... elif)

原网站

版权声明
本文为[Faith, faith]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/163/202206121329186479.html