Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
289931d
Update if.md and loops.md
georgerahul24 Dec 30, 2020
6f1d882
Update if.md and loops.md
georgerahul24 Dec 30, 2020
9181d7a
Fixed Typo
georgerahul24 Jan 1, 2021
d5cf490
Removed unnecessary comments in the programmes
georgerahul24 Jan 1, 2021
848b0f3
Merge branch 'Akuli:master' into master
georgerahul24 Jul 1, 2021
33049e1
Update basics/loops.md
georgerahul24 Jul 13, 2021
a509a8e
Update basics/loops.md
georgerahul24 Jul 13, 2021
8fd60e4
Update basics/answers.md
georgerahul24 Jul 13, 2021
1eeda48
I have made the necessary changes as requested
georgerahul24 Jul 13, 2021
2ce1e7d
Update LICENSE
georgerahul24 Jul 13, 2021
7a93d2a
Update basics/loops.md
georgerahul24 Jul 13, 2021
39f94f5
Update basics/loops.md
georgerahul24 Jul 13, 2021
546f769
Update basics/handy-stuff-strings.md
georgerahul24 Jul 13, 2021
afafcdb
Update basics/answers.md
georgerahul24 Jul 13, 2021
9f35e3a
updated handy-stuff-strings.md
georgerahul24 Jul 13, 2021
e69aad0
Merge remote-tracking branch 'origin/master'
georgerahul24 Jul 13, 2021
ea0d4e6
Update basics/answers.md
georgerahul24 Jul 13, 2021
69e62b3
updated handy-stuff-strings.md
georgerahul24 Jul 13, 2021
34693ce
Merge branch 'master' of https://github.com/georgerahul24/python-tuto…
georgerahul24 Jul 13, 2021
b2e23df
updated handy-stuff-strings.md
georgerahul24 Jul 13, 2021
7e79089
Update basics/answers.md
georgerahul24 Jul 30, 2021
8cbe80f
Update basics/answers.md
georgerahul24 Jul 30, 2021
0e407c3
Update basics/answers.md
georgerahul24 Jul 30, 2021
228c862
Update basics/answers.md
georgerahul24 Jul 30, 2021
ea2f5f7
Update basics/answers.md
georgerahul24 Jul 30, 2021
b9ef729
Update basics/answers.md
georgerahul24 Jul 30, 2021
f8549e8
Update basics/answers.md
georgerahul24 Jul 30, 2021
985a52f
Update basics/handy-stuff-strings.md
georgerahul24 Jul 30, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion basics/answers.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,18 @@ isn't exactly like mine but it works just fine it's ok, and you can
print("Access denied.")
```

Again, this is not a good way to ask a real password from the user.
Again, this is not a good way to ask a real password from the user.

7. Here, we create a new variable `palindrome_check`.We use this variable to store the reversed string(of`palindrome_input`). Then we check if the string that was given(`palindrome_input`)
and the reversed sting(`palindrome_check`) is the same using a simple `if loop`
```python
palindrome_input=input("Type the number to check:")
palindrome_check=palindrome_input[::-1] #Reverses the string
if palindrome_input==palindrome_check:
print(f"This number is a palindrome")
else:
print("This number is not a palindrome")
```

## Handy stuff: Strings

Expand Down Expand Up @@ -296,6 +307,29 @@ isn't exactly like mine but it works just fine it's ok, and you can
print(converted_numbers)
```

5. ``` python
rows=int(input("Type the number of rows needed:"))
for row in range(1,rows+1):
for column in range(1,row+1):
print(column,end=" ")
print()#creates a new line for the next row
Comment thread
georgerahul24 marked this conversation as resolved.
Resolved
```
We actually use the first `for` loop to loop through the number of rows needed.Now,
through that `for` loop we got the row number.
Now,the next `for` loop helps us to identify which numbers should be printed on the row which we currently accessed from the `for` loop above



6. The idea is more or less same as in the above question.
```python
rows=int(input("Type the number of rows needed:"))

for row in range(1, rows + 1):
for column in range(row,rows+1):
print(column, end=' ')
print()
```

## Trey Hunner: zip and enumerate

1. Read some lines with `input` into a list and then enumerate it.
Expand Down
1 change: 1 addition & 0 deletions basics/if.md
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ you are asked to "fix code", feel free to add missing blank lines.
`Access denied` or `You didn't enter anything` depending on whether
the user entered the correct password, a wrong password, or nothing
at all by pressing Enter without typing anything.
7. Make a programme to take the input from the user and check if it is a palindrome.
Comment thread
georgerahul24 marked this conversation as resolved.
Resolved

The answers are [here](answers.md#if-else-and-elif).

Expand Down
20 changes: 19 additions & 1 deletion basics/loops.md
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,25 @@ while True:
number = int(number)
print(numbers)
```

5. Make a programme to get a pyramid like shown in the OUTPUT section where user can type the number of rows needed
Comment thread
georgerahul24 marked this conversation as resolved.
Resolved
```
OUTPUT for 5 rows
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
```

6. Make a programme to get a pyramid like shown in the OUTPUT section where user can type the number of rows needed

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
6. Make a programme to get a pyramid like shown in the OUTPUT section where user can type the number of rows needed
6. Modify your program from the previous exercise to print this instead:

```
OUTPUT when rows is equal to 5
Comment thread
georgerahul24 marked this conversation as resolved.
Resolved
1 2 3 4 5
2 3 4 5
3 4 5
4 5
5
```
The answers are [here](answers.md#loops).

***
Expand Down