0% found this document useful (0 votes)
2 views

Python Cheatsheet (1)

This document is a Python cheat sheet that covers basic syntax, including how to display output using the print function and how to take user input with the input function. It also explains typecasting for input values to integers and floats, as well as the range function for generating sequences of numbers. Overall, it serves as a quick reference guide for fundamental Python programming concepts.

Uploaded by

amolgangwar42
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Python Cheatsheet (1)

This document is a Python cheat sheet that covers basic syntax, including how to display output using the print function and how to take user input with the input function. It also explains typecasting for input values to integers and floats, as well as the range function for generating sequences of numbers. Overall, it serves as a quick reference guide for fundamental Python programming concepts.

Uploaded by

amolgangwar42
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

Python CheatSheet

Aditi

B a s ic s
Basic syntax from the python programming language

Showing Output To User


The print function s used to display or print output as follows

print("C ontent th at you wanna p rin t on screen")

we can display the content present in object using prit function as follows:-

var1 ="Aditi"
p rin t("H i my name is : " ,v a r 1 )

Taking Input From the User


The input function is used to take input as string or character from the user as follows:

var1 = in p u t( " E n te r your n a m e :" )


print("My name is : " , v a r 1 )

To take input n form of other datatypes we need to typecaste them as follows:-


To take input as an integer:-

v a r 1 = in t( in p u t(" e n te r the integ er v a lu e ") )


p rin t(v a r1 )

To take nput as an float:-

var1=float(input("enter the float value"))


print(var1)

range Function
range function returns a sequence of numbers,eg, numbers starting from 0 to n-1 for
range(o,n)

You might also like