Computer Science- Programming
- Created by: Claudiatorresquiros
- Created on: 20-08-18 10:54
Programming
Python Output
To output somthing you use the command "print" - print ("Hello!")
Input Command
input("Enter the password")
If you want to add the input to a variable:
Password=input("Enter the password")
Then you can output the variable:
Password=input("Enter the password")
print("Your new password is", Password)
Assign a value
You can assign an integer- password= int(input("..."))
or a string- Name = "Alison"
or a float number (fraction)- float(input("..."))
Calculated operations
+ - * /
Python if...
==- equal to
!= - not equal to
< - less than
> - more than
If - logical test- colon (:)
if age < 15: (after the colon there always is an indentation)
print ("Sorry you cant come back")
else:
print("You can buy a ticket")
If there are more than 2 options you can use "elif"
if- elif-elif-elif-else
Repetition
Counter controlled: the computer counts how many times the loop repeats- you can use this…
Comments
Report
Report