



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Introduction to Python language of programming.
Typology: Study notes
1 / 5
This page cannot be seen from the preview
Don't miss anything!




Python print function and variables Print (“Hello word”)
My_favorite_number = 5 Print (My_favorite_number) Pi = 3. Print (pi) My_favorite_number = pi Print (My_favorite_number) To print more than one variable and data in a single print statement, we can separate them by commas Example: Print (“City:”, “Kathmandu”) We can print variables and string in a single statement Example: city = “Kathmandu” Print (“City:”, city) city = “Kathmandu” kfc_locations = 3 print (“City:”, city, “KFC Locations:”, kfc_locations)
Number = input (“Enter number: “) Print (type(Number)) Number1 = 5 Print (type(Number1)) Number2 = 5. Print (type(Number2)) Number = input (“Enter a number: “) Print (Number) **It is not possible to take integer and float input using the input function however, we can convert the string to a number after we take the input Number = input (“Enter a number: “) Number = int(Number) Print (Number) Number = input (“Enter a number: “) Number = int(Number) Print (type(Number)) Number = int(input (“Enter a number: “)) Print (type(Number)) Number = float(input (“Enter a number: “)) Print (type(Number))
However, python cannot convert every string to numbers (non-numeric) Number = float(input(“Enter a number: “)) Print (type(Number)) What we have learned?