Concept: Using type
Using the Python type() function
type() returns the data type of Python objects
str, int, float
What does using type() reveal?
str: when type() returns str that means it has evaluated a string characters (numbers, letters, punctuation...) in quotes
int: when type() returns int that means it has evaluated an Integer (+/- whole numbers)
float: when type() returns float that means it has evaluated decimal numbers (e.g. 3.33, 0.01, 9.9999 and 3.0), ...more later in the course
Example
Read and run the code for each sample
[ ] read and run the code
type("Hello World!")
type(501)
type(8.33333)
student_name = "Colette Browning"
type(student_name)
Task 1: multi-part
Using type()
Complete the "identify data types" tasks by assigning values to the variable bucket and using type()
[ ] show the type after assigning bucket = a whole number value such as 16
[ ] show the type after assigning bucket = a word in "double quotes"
[ ] display the type of 'single quoting' (use single quotes)
[ ] display the type of "double quoting" (use double quotes)
[ ] display the type of "12" (use quotes)
[ ] display the type of 12 (no quotes)
[ ] display the type of -12 (no quotes)
[ ] display the type of 12.0 (no quotes)
[ ] display the type of 1.55
[ ] find the type of the type(3) statement (no quotes) - just for fun
Sur cette page du site, vous pouvez voir la vidéo en ligne Concept: Using type - Introduction to Python: Absolute Beginner Module 1 Video 9 durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Book Simplifiers 10 juillet 2021, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 21 fois et il a aimé 2 téléspectateurs. Bon visionnage!