This commit is contained in:
winneratwin 2022-03-02 21:43:35 +00:00
parent 1323073df1
commit d3e90b1de1
Signed by: winneratwin
GPG Key ID: CDBC42F8803D689E
13 changed files with 96 additions and 0 deletions

3
week 3/Can you.....md Normal file
View File

@ -0,0 +1,3 @@
Write a program that counts for the user. Let the user enter the starting number, the ending number, and the amount by which to count
Create a program that gets a message from the user and then prints it out backward

2
week 3/Can you.....py Normal file
View File

@ -0,0 +1,2 @@
out = input("string: ")
print(out[::-1])

View File

@ -0,0 +1,7 @@
Ask the user to input a sentence. Check whether it is a palindrome - i.e. it reads the same reading backwards, as forwards.
Hint: check the Python documentation for how to reverse a list or string.
You can look at this video to get some ideas for testing ;)
https://youtu.be/gAfIikFnvuI

View File

@ -0,0 +1,2 @@
out = input("string: ")
print("Is palendrome",out[::-1] == out)

View File

@ -0,0 +1,3 @@
How to check inputs to make sure that expected numbers are actually numbers. There are a number of ways to do this but the easiest is probably to use a try and except block.
files: numbercheck.PNG

View File

@ -0,0 +1,9 @@
def int_input(text):
while True:
try:
user_input = int(input(text))
return user_input
except Exception:
print("error")
else:
break

View File

@ -0,0 +1,3 @@
When you write a program you may find that you need to count. In combination with the for loop, you can use Python's range( ) function to count in all kinds of ways.
files: counter.py

5
week 3/Loopy string.md Normal file
View File

@ -0,0 +1,5 @@
Understanding for Loops
All sequences are made up of elements. A string is a sequence in which each element is one character. A for loop marches through (or iterates over) a sequence one element at a time.
files: loopy_string.py

View File

@ -0,0 +1,9 @@
Design a program to emulate the game Rock, Paper, Scissors.
Use Ascii art to display the choices (http://chris.com/ascii/)
- Play against the computer (randomly generate an answer)
Code up your design
Test

View File

@ -0,0 +1,26 @@
rock="""
_______
---' ____)
(_____)
(_____)
VK (____)
---.__(___)
"""
paper="""
_______
---' ____)____
______)
_______)
VK _______)
---.__________)
"""
scissors="""
_______
---' ____)____
______)
__________)
VK (____)
---.__(___)
"""

17
week 3/counter.py Normal file
View File

@ -0,0 +1,17 @@
# Counter
# Demonstrates the range() function
print ("Counting:")
for i in range(10):
print (i)
print ("\n\nCounting by fives:")
for i in range(0, 50, 5):
print (i)
print ("\n\nCounting backwards:")
for i in range(10, 0, -1):
print (i)
x = input("\n\nPress the enter key to exit.\n")

10
week 3/loopy_string.py Normal file
View File

@ -0,0 +1,10 @@
# Loopy String
# Demonstrates the for loop with a string
word = input("Enter a word: ")
print ("\nHere's each letter in your word:")
for letter in word:
print (letter)
x = input("\n\nPress the enter key to exit.")

BIN
week 3/numbercheck.PNG Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB