All language subtitles for 类型转换

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified) Download
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranî)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu

Original subtitles

all right everybody so we are moving on to typecasting

typecasting is the process of converting a variable

from one data type to another

we have various functions to convert a value

or variable to a string

an integer a float or a boolean

let's create some variables

we will create a name variable

type in your full name

an age make up some age

a GPA for grade point average let's say minus 3.2

and a boolean of is student

are we currently a student

let's say that's true

now you actually could get the data type of a variable

or a value by using the type function

then pass in a value or variable

however when I run this there's no output

so I need a print statement

we will print what is returned by B type function

get the type of our name variable then print it

so our name variable is a string str

our age variable

is an integer and INT

GPA is a float

is student is a boolean

using these typecast functions

we can convert from one data type to another

here's how

let's start with something simple

let's convert our GPA to an integer

currently it's afloat

I will reassign GPA

use the INT function to typecast to an integer

then pass in my GPA

at the end we will print R GPA

if we typecast 3.2 to a whole integer

what would the result be

a whole integer of 3

we truncate the decimal portion

let's convert our age to a floating point number

we will reassign our variable of age

use the typecast function of float

then insert our age variable

let's print our age variable

and it should be a floating point number 25 point 0

now we'll cover strings

let's typecast our age to be a string

age equals call the typecast function of string

str passenger age variable

so the result is still going to appear the same

25 however it's a string not an integer

and to prove that

I will enclose my age variable with the type function

the type of variable age is a string

it would be the same as if we are taking this number

and enclosing it within quotes

so this would make a difference

because let's say that I add one to age

age plus equals 1

well we would get a type air

can only concatenate strings not integers to a string

however if I were to add a string of 1 to the end

we would be using string concatenation

so let's say it's my birthday and I add 1 to 25

while since we're working with strings now

the result would be 251

I am 251 years old

so strings and numbers behave differently

with numbers

we can use them within arithmetic expressions

strings not so much

we will take our name variable

and typecast it to a boolean

name equals call the typecast function of Bull

Pass in our name variable

this has an interesting result

so I'm going to print name

bullions are either true or false

if I typecast my string of text into a bullion

that gives me true

now it really doesn't matter what I write here

if I were to change my name to a single character

such as B this would still be true

if our string variable

was empty there were no characters within it

that would actually give us false

we could use this to check to see if somebody

enters in their name

or not if somebody types in their name

then we typecast it to a boolean

if somebody skips entering in their name

that would return false

we could reprompt the user to enter in their name again

art everybody so that is typecasting

it is the process of converting a variable

from one data type to another

this is especially useful with handling user input

because user input is always a string

there may be

at times where you want to convert it to an integer

a float or a boolean

and well everybody that is typecasting in Python

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.