Week one and two challenges
parent
22a5e0ac9a
commit
328d5b54a9
@ -0,0 +1,4 @@
|
||||
## What happens when you put an expression on a line without a print command in a python script?
|
||||
### As mentioned earlier on print command are use to display information when a python program is being written in a script file. No it will not print.
|
||||
## What does putting a comma at the end of a print command do? In python putting comma keep string on the same line without creating a newline.
|
||||
## What does putting a print command on a line by itself doe? In python print statment are intended to print out information on the screen so having a print statement without an expression the print statement will display a empty or blank output.
|
@ -0,0 +1,14 @@
|
||||
print("Experiment 1: ")
|
||||
1 + 8
|
||||
print(1 + 2)
|
||||
"How come this did not print?"
|
||||
print("but this did?")
|
||||
print()
|
||||
print()
|
||||
|
||||
print("Experiment 2:")
|
||||
for number in 2, 4, 6:
|
||||
print(2 * number)
|
||||
|
||||
for number in 2, 4, 6:
|
||||
print(3 * number, end="")
|
@ -0,0 +1,19 @@
|
||||
|
||||
from random import randint
|
||||
|
||||
#Challenges3
|
||||
number_one = randint(1,10)
|
||||
number_two = randint(1,10)
|
||||
answer = int(input(f"What is {number_one} time {number_two} ?\n"))
|
||||
if (number_one * number_two == answer):
|
||||
print("correct")
|
||||
else:
|
||||
print("wrong")
|
||||
|
||||
#Challenge 4
|
||||
number_one = randint(1,10)
|
||||
for number in range(number_one):
|
||||
if number >= 5:
|
||||
print(number)
|
||||
|
||||
|
@ -0,0 +1,40 @@
|
||||
from random import randint
|
||||
#Challenge1
|
||||
|
||||
number_one = randint(1,10)
|
||||
number_two = randint(1,10)
|
||||
print(f"Challenge one\nWhat is {number_one} times {number_two}")
|
||||
answer = number_one * number_two
|
||||
print(answer)
|
||||
|
||||
#Challenge2
|
||||
number_one = randint(1,10)
|
||||
number_two = randint(1,10)
|
||||
print(f"Challenge two\nWhat is {number_one} plus {number_two}")
|
||||
|
||||
result = number_one + number_two
|
||||
print(result)
|
||||
|
||||
|
||||
#Challenges3
|
||||
|
||||
number_one = randint(1,10)
|
||||
number_two = randint(1,10)
|
||||
answer = int(input(f"Challenge three\nWhat is {number_one} times {number_two} ?\n"))
|
||||
|
||||
|
||||
#Challenge4
|
||||
number_one = randint (1,10)
|
||||
print(str(number_one) * 5)
|
||||
|
||||
#Challenges5
|
||||
|
||||
number_one = randint(1,10)
|
||||
number_two = randint(1,10)
|
||||
answer = int(input(f"Challenge five\nWhat is {number_one} times {number_two} ?\n"))
|
||||
if number_one * number_two == answer:
|
||||
print(f"Your answer {answer} is correct!!")
|
||||
else:
|
||||
print(f"Wrong")
|
||||
|
||||
|
Loading…
Reference in New Issue