Popcorn Hacks

#Popcorn Hack 1

x_values = [1,2,3]

for x in x_values:
    func1=x+2
    func2=3*func1
    func3=func2-4
    print("for x =" +str(x) + ", y is=" + str(func3))
for x =1, y is=5
for x =2, y is=8
for x =3, y is=11
#Popcorn Hack 2

#num1 = 20
#num2 = num1 /2 
#num3 = num2 * 10 + 3
#print(num3)

print("The code above will print: " + str(103))
The code above will print: 103
#Popcorn Hack 3

num1=int(input("Enter a number: "))

num2 = num1 /2 
num3 = num2 * 15 + 3
num4 = num3 % 5
num5 = num4

print(num3)
115.5
# Popcorn Hack 4

name_len = len("Ronit")
print(name_len)


full_name = "Ronit" + "Thomas"
print (full_name)

substring = full_name[2:6]
print("3rd through 6th letters are: ")
print (substring)

5
RonitThomas
3rd through 6th letters are: 
nitT
# Robot Style AP Problem

#move_forward()
#move_forward()
#move_forward()
#rotate_left()
#move_forward()
#move_forward()
#rotate_right()
#move_forward()
#move_forward()
#move_forward()

Homework

#Use an algorithm to find certain values of the Fibonacci sequence. For example, your code should output the nth index in the sequence. An example of how the sequence works is 0,1,1,2,3,5,8,13. The pattern is you add the previous 2 numbers together to get the new number. \
# 0,1,1,2,3,5,8,13

sequence = [0, 1] 

user = int(input("How numbers do you want in your sequence?"))

for i in range(0,user):
    next_fib = sequence[-1] + sequence[-2]
    sequence.append(next_fib)

print(sequence)

user = int(input("What index of the sequence do you want to print?"))
print("Index #"  + str(user) + " is: " + str(sequence[user]))
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025]
Index #15 is: 610