Changes

Jump to: navigation, search

OPS435 Python Lab 2

19 bytes added, 01:55, 25 May 2017
PART 1 - INDENTATION AND IF LOGIC
:'''Perform the following steps:'''
:#Open ipython3<source>
ipython3
</source>
:#First lets start out with a very basic script. This script will use variables to print out specific information to the screen. Make the script '''lab2a.py''' with the following content.<source>
#!/usr/bin/env python3
</source>
:#In the above example we are making a comparison between the value we enter int the input() function, which will be saved into the password variable, and with the word 'P@ssw0rd'. The '==' stands for is equal to, we are asking if the password variable is equal to the word 'P@ssw0rd'. If this condition is True, it will run the code indented below, if the condition is False, it will not run the code. Try experimenting with different combinations of passwords.
 :#We If statements can also use this be used to compare numbers, and we will also learn a new function here as welluse functions. The function 'len()' can be used to give us the length of words and other variables. We can use this 'len()' function to give us the number of arguments provided to our script by using 'len(sys.argv)' and it should return a number. Below we are also using '!='. Which stands for not equal to. <source>
import sys
198
edits

Navigation menu