Adding as many examples as I've converted so far.
This commit is contained in:
parent
0aa0875c42
commit
543bc78e51
@ -22,8 +22,8 @@ There are a few things you need to get started, I would check these off in order
|
||||
- I recommend VSCode, because if you decide to switch to Java or C++ later, that's what you'll use, but PyCharm would also be a decent choice
|
||||
- A Supported OS
|
||||
- I have tested Windows 10 and Ubuntu 18.04 LTS with success
|
||||
- Python 3.6 x64
|
||||
- It must be 3.6! Don't install the latest version, without going into great detail, there are certain things that need to be installed, and if you're using a newer version than 3.6, Python will automatically try to recompile certain things and you'll run into a ton of errors that aren't easy to solve.
|
||||
- Python 3.7 x64
|
||||
- It must be 3.7! Don't install the latest version, without going into great detail, there are certain things that need to be installed, and if you're using a newer version than 3.7, Python will automatically try to recompile certain things and you'll run into a ton of errors that aren't easy to solve.
|
||||
- The Most Recent Version of PIP
|
||||
- PIP is how you install Python modules, once Python is installed, you should make sure you have the most recent version of PIP
|
||||
- On Windows, open command prompt and type the following command
|
||||
@ -31,4 +31,4 @@ There are a few things you need to get started, I would check these off in order
|
||||
- The Most Revent Version of RobotPy
|
||||
- RobotPy is the existing modules that contain the things we need to write robot code
|
||||
- On Windows, open command prompt and type the following command
|
||||
`pip install robotpy\[all\]`
|
||||
- `pip install robotpy\[all\]`
|
||||
|
1
2 - Console In and Out/Challenge/README.md
Normal file
1
2 - Console In and Out/Challenge/README.md
Normal file
@ -0,0 +1 @@
|
||||
Build a program that requests a user's name, and then prints a greeting.
|
2
2 - Console In and Out/Challenge/main.py
Normal file
2
2 - Console In and Out/Challenge/main.py
Normal file
@ -0,0 +1,2 @@
|
||||
userName = input("Please enter your name: ")
|
||||
print("Hello " + userName)
|
0
2 - Console In and Out/README.md
Normal file
0
2 - Console In and Out/README.md
Normal file
6
2 - Console In and Out/main.py
Normal file
6
2 - Console In and Out/main.py
Normal file
@ -0,0 +1,6 @@
|
||||
print("Hello World!")
|
||||
|
||||
print("This is console out!")
|
||||
|
||||
userInput = input("Write some text: ")
|
||||
print("You wrote: " + userInput)
|
1
3 - Variables and Basic Math/Challenge/README.md
Normal file
1
3 - Variables and Basic Math/Challenge/README.md
Normal file
@ -0,0 +1 @@
|
||||
Build a program that requests three numbers from the user, and performs a math operation on them and prints the result
|
5
3 - Variables and Basic Math/Challenge/main.py
Normal file
5
3 - Variables and Basic Math/Challenge/main.py
Normal file
@ -0,0 +1,5 @@
|
||||
firstValue = float(input("Value 1: "))
|
||||
secondValue = float(input("Value 2: "))
|
||||
thirdValue = float(input("Value 3: "))
|
||||
|
||||
print(str(firstValue) + " / " + str(secondValue) + " - " + str(thirdValue) + " = " + str(firstValue / secondValue - thirdValue))
|
0
3 - Variables and Basic Math/README.md
Normal file
0
3 - Variables and Basic Math/README.md
Normal file
24
3 - Variables and Basic Math/main.py
Normal file
24
3 - Variables and Basic Math/main.py
Normal file
@ -0,0 +1,24 @@
|
||||
someString = "Some string value"
|
||||
lifeUniverseEverything = 42
|
||||
someFloat = 2.22
|
||||
bananasAreGood = True
|
||||
|
||||
string = input("Enter a string: ")
|
||||
intValue = int(input("Enter an integer: "))
|
||||
booleanValue = True if input("Enter a True/False value: ") == 'True' else False
|
||||
floatValue = float(input("Enter a float (decimal) value: "))
|
||||
|
||||
print("The values you entered")
|
||||
print("String: " + string)
|
||||
print("Integer: " + str(intValue))
|
||||
print("Boolean: " + str(booleanValue))
|
||||
print("Float: " + str(floatValue))
|
||||
|
||||
firstNumber = float(input("Enter the first floating (decimal) value: "))
|
||||
secondNumber = float(input("Enter the second floating (decimal) value: "))
|
||||
|
||||
print(str(firstNumber) + " + " + str(secondNumber) + " = " + str(firstNumber + secondNumber))
|
||||
print(str(firstNumber) + " - " + str(secondNumber) + " = " + str(firstNumber - secondNumber))
|
||||
print(str(firstNumber) + " * " + str(secondNumber) + " = " + str(firstNumber * secondNumber))
|
||||
print(str(firstNumber) + " / " + str(secondNumber) + " = " + str(firstNumber / secondNumber))
|
||||
print(str(int(firstNumber)) + " % " + str(int(secondNumber)) + " = " + str(int(firstNumber) % int(secondNumber)))
|
6
4 - If Else and Logical Operators/Challenge/README.md
Normal file
6
4 - If Else and Logical Operators/Challenge/README.md
Normal file
@ -0,0 +1,6 @@
|
||||
Build a program that requests the user's age, and return one of the following:
|
||||
- <= 18 - You're a youngin'
|
||||
- > 18 AND <= 35 - The early adult years
|
||||
- > 35 AND <= 55 - Middle aged, time to buy a really expensive car
|
||||
- > 55 AND <= 64 - Getting older...
|
||||
- > 64 - Retirement! Time to live out the golden years
|
12
4 - If Else and Logical Operators/Challenge/main.py
Normal file
12
4 - If Else and Logical Operators/Challenge/main.py
Normal file
@ -0,0 +1,12 @@
|
||||
age = int(input("Enter your age: "))
|
||||
|
||||
if age <= 18:
|
||||
print("You're a youngin'")
|
||||
elif age > 18 and age <= 35:
|
||||
print("The early adult years")
|
||||
elif age > 35 and age <= 55:
|
||||
print("Middle aged, time to buy a really expensive car")
|
||||
elif age > 55 and age <= 64:
|
||||
print("Getting older...")
|
||||
else:
|
||||
print("Retirement! Time to live out the golden years.")
|
0
4 - If Else and Logical Operators/README.md
Normal file
0
4 - If Else and Logical Operators/README.md
Normal file
39
4 - If Else and Logical Operators/main.py
Normal file
39
4 - If Else and Logical Operators/main.py
Normal file
@ -0,0 +1,39 @@
|
||||
intValue1 = int(input("Enter Int Value 1: "))
|
||||
intValue2 = int(input("enter Int Value 2: "))
|
||||
|
||||
if intValue1 == intValue2:
|
||||
print("Int Value 1 equals Int Value 2")
|
||||
else:
|
||||
print("Int Value 1 does not equal Int Value 2")
|
||||
|
||||
if intValue1 > intValue2:
|
||||
print("Int Value 1 is greater than Int Value 2")
|
||||
elif intValue1 < intValue2:
|
||||
print("Int Value 1 is less than Int Value 2")
|
||||
else:
|
||||
print("Int Value 1 is equal to Int Value 2")
|
||||
|
||||
if intValue1 < 100 and intValue1 > 50:
|
||||
print("Int Value 1 is greater than 50 AND less than 100")
|
||||
else:
|
||||
print("Int Value 1 is NOT greater than 50 AND less than 100")
|
||||
|
||||
if intValue2 < 25 or intValue2 > 50:
|
||||
print("Int Value 2 is less than 25 OR greater than 50")
|
||||
else:
|
||||
print("Int Value 2 is NOT less than 25 OR greater than 50")
|
||||
|
||||
stringValue1 = input("Enter String Value 1: ")
|
||||
stringValue2 = input("Enter String Value 2: ")
|
||||
|
||||
if stringValue1 == stringValue2:
|
||||
print("String Value 1 is equal to String Value 2")
|
||||
elif stringValue1.casefold() == stringValue2.casefold():
|
||||
print("String Value 1 is equal to String Value 2 if you ignore case")
|
||||
else:
|
||||
print("String Value 1 does not equal String Value 2")
|
||||
|
||||
if intValue1 != 42:
|
||||
print("Int Value 1 does not equal 42")
|
||||
else:
|
||||
print("Int Value 1 equals 42")
|
1
5 - Random Numbers and For Loops/Challenge/README.md
Normal file
1
5 - Random Numbers and For Loops/Challenge/README.md
Normal file
@ -0,0 +1 @@
|
||||
Write a program that requests an integer from the user, and prints that many random numbers AND prints hte sum and average of those numbers.
|
15
5 - Random Numbers and For Loops/Challenge/main.py
Normal file
15
5 - Random Numbers and For Loops/Challenge/main.py
Normal file
@ -0,0 +1,15 @@
|
||||
import random
|
||||
|
||||
numberToRandomize = int(input("Number of random values to create: "))
|
||||
|
||||
sum = 0.0
|
||||
|
||||
for i in range(numberToRandomize):
|
||||
randomNumber = random.random() * 100 + 1
|
||||
|
||||
print("Random Number " + (i + 1) + ": " + str(randomNumber))
|
||||
|
||||
sum += randomNumber
|
||||
|
||||
print("Sum = " + str(sum))
|
||||
print("Average = " + str(sum / numberToRandomize))
|
0
5 - Random Numbers and For Loops/README.md
Normal file
0
5 - Random Numbers and For Loops/README.md
Normal file
10
5 - Random Numbers and For Loops/main.py
Normal file
10
5 - Random Numbers and For Loops/main.py
Normal file
@ -0,0 +1,10 @@
|
||||
import random
|
||||
|
||||
for i in range(10):
|
||||
print("Index Number: " + str(i))
|
||||
|
||||
for i in range(5):
|
||||
print("Int Value " + str(i + 1) + ": " + str(random.randint(1, 100)))
|
||||
print("Float Value " + str(i + 1) + ": " + str(random.random() * 100 + 1))
|
||||
print("Boolean Value " + str(i + 1) + ": " + str(True if random.random() > .5 else False))
|
||||
|
@ -0,0 +1 @@
|
||||
Write a program that generates a random number, and repeatedly asks the user to guess the number, telling them if they're too low, too high, or if they guess correctly. The program should end once they guess the correct number.
|
@ -0,0 +1,16 @@
|
||||
import random
|
||||
|
||||
randomValue = random.randint(1, 100)
|
||||
|
||||
guess = -1
|
||||
|
||||
while randomValue != guess:
|
||||
guess = int(input("Guess the number: "))
|
||||
|
||||
if guess < randomValue:
|
||||
print("You're too low")
|
||||
elif guess > randomValue:
|
||||
print("You're too high")
|
||||
else:
|
||||
print("You guessed the right number")
|
||||
|
19
6 - While Loops Break Continue and Loop Translation/main.py
Normal file
19
6 - While Loops Break Continue and Loop Translation/main.py
Normal file
@ -0,0 +1,19 @@
|
||||
for i in range(10):
|
||||
if i == 2 or i == 5:
|
||||
continue
|
||||
elif i == 7:
|
||||
break
|
||||
|
||||
print("For Index Number: " + str(i))
|
||||
|
||||
counter = 0
|
||||
|
||||
while counter < 10:
|
||||
if counter == 2 or counter == 5:
|
||||
counter += 1
|
||||
continue
|
||||
elif counter == 7:
|
||||
break
|
||||
|
||||
print("While Index Number: " + counter)
|
||||
counter += 1
|
Loading…
Reference in New Issue
Block a user