User as float, print half of the that number
list,print all element from the list using loop
print Fibonacci series between 0 to 50 using loop
The areaOfEllipse using pir2r1 ( two parameter)
User_inputuser_input = input("Enter a value: ") Comparing Values:When you compare two values, the result is a Boolean (True or False) E.g. 2 == 3 is False == is equal to != is not equal to < less than <= less than or equal to > greater than >= greater than or equal to and or not True or anything is always True False and anything is always False Combining Strings (Concatenation)"hi" + "there" == "hithere" "hi" * 5 == "hihihihihi" Converting between different data types:word = str(3) #converts 3 to a string "3" num = int("3.5") #converts "3.5" to an integer 3 num = float("3") #converts "3" to a float 3.0 |
The output of follwing code
print alleven numbers from 1 100 using while loop
use a for loop to print the following
receive input from user, convert integer,print , 5
output of the program
Data typesString - a list of characters e.g. "abc123$%^", or empty string "" Integer - whole numbers, and negative numbers e.g. -5, 0, 2 Floating Point - decimal numbers e.g. 1.5, 2.0, -2.99 Boolean - True or False Printing values:print("hello", "there") #displays hello there print("hello" + "there") #displays hellothere Comments# hashtag – everything after # is a comment not code """ Double quote - Multi-line comment, everything in between three double quotes is a comments """ ''' Single quote - Multi-line comment, everything in between three single quotes is a comments ''' the loop doesn't go forever
|
Receive number from user, number is determine by 3
MultiplicationTable
Making number is negative, Zero or positive
print all even number from -100 to -1 (while loop)
positive integer,negative print HM odd, even
Basic Math Operations:+ addition, - subtraction / divide with answer as a float. E.g. 5/2 == 2.5 // divide with answer as an integer. E.g. 5//2 == 2 * multiply exponent. E.g. 2 power 3 == 2 3 % modulo. Gives the remainder when dividing e.g. 33 % 10 == 3 All math operations use the sa print out fifth character from the variable
convert integer and multiply by 10 loop
|
Cheatography
https://cheatography.com
Created By
Metadata
Favourited By
Comments
No comments yet. Add yours below!
Add a Comment
More Cheat Sheets by Chutima Rakyu