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
In questa pagina del sito puoi guardare il video online Concept: Using type - Introduction to Python: Absolute Beginner Module 1 Video 9 della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Book Simplifiers 10 luglio 2021, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 21 volte e gli è piaciuto 2 spettatori. Buona visione!