Language:
Contact Us

Search

Notes: Ritu Coding with Python

  • Share this:

14 April 23

Assignment for Ritu.

Buggy Code (Part 1)
https://edabit.com/challenge/CjXamaNRmKxwkmBxq

Convert Hours into Seconds
https://edabit.com/challenge/nyeNvKWdDFKRAk4Da

Return the Remainder from Two Numbers
https://edabit.com/challenge/KWoj7kWiHRqJtG6S2

Convert Age to Days
https://edabit.com/challenge/xbZR26rHMNo32yz35

Find the Perimeter of a Rectangle
https://edabit.com/challenge/Yx2a9B57vXRuPevGh

The Power of ____
https://edabit.com/challenge/xWSjvoH7mEkSnqS7H

Boolean to String Conversion
https://edabit.com/challenge/QQp2o22huzBCkHesy

The Farm Problem
https://edabit.com/challenge/QzXtDnSZL6y4ZcEvT


Invert Color
https://edabit.com/challenge/i6hY9JSjQK4jcaB6i

Basic Calculator
https://edabit.com/challenge/ZdnwC3PsXPQTdTiKf

19 Sep 22:

Class work : Turtle Graphics

Assignment:

1) Write a function to draw a star.

2) Draw a row of 5 starts.

3) Draw 4 rows each having 7 stars.

 

20 Aug 22:

Assignment :

1) Assignment 1
2) Assignment 2

Class work : Conditions, Arthmetic sums practice.

6 Aug 2022:

Assignment :

1) In the programme bleow print all the words separately on each line.

2) Write a function that counts 1 letter words, 2 letter words, 3 letter words and so on.

Class Work:

def word_count(str):
    counts = dict()
    words = str.split()

    for word in words:
        if word in counts:
            counts[word] += 1
        else:
            counts[word] = 1

    return counts

print( word_count('the quick brown fox jumps over the lazy dog.'))

 

26 June 2022:

Assignment:

1) Write a programme to generate 2 random numbers from 1 to 6 (dice).This is unique dice so numbers generated should always unique.
So dice should not generate eg. 1-1 or 2-2 etc.

2) Write a dice programme which asks for 2 players name. Plays the dice and declare the winner's name. It favours the player with name "RITU".

Topics covered : Random, functions, parameters, keywords

1 June 2022:

Assignment

1) Get a string from user. Print the string starting with 4th character.

2) Get a string from user. Print the string starting with 7th character.

3) Get a string from user and print last 4 character from the string.

4) Get a string from user and print last 4 characters and first 4 characer from the string.

Class Work:

Thonny - Session 2, Revision

23 May 2022:

Assignement:

1) Write a programm to get 2 strings and weather 2 strings are same or different.

2) Using the while loop print the followng numbers in one line:
9 10 11 29 30 31 49 50 51 69 70 71

3) Using while loop print numbers upto 100 in the table of 7 .

4) Get a string from user. Print the string starting with 4th character.

5) Get a string from user. Print the string starting with 7th character.

6) Get a string from user and print last 4 character from the string.

7) Get a string from user and print last 4 characters and first 4 characer from the string.

Topics covered : List, Indexing, Slicing (with :)

 

16 May 2022:

Assignment :

1) Write  programm to get 2 number from user. and print max of 2 numbers.

2) Write  programm to get 2 number from user. and print min of 2 numbers.

3) Use while to get 5 names from user and print.

4) Get a number from user. Print weather it is divisible by 4.

Topics Covered:
Revison : if, else, while, min(), max()
format : f" ... "

25 Apr 2022:

Assignment: 

1) Write a programme to print following pattern (n = 5) using while loop.
[All even numbers are printed as 0]
1
2
3
4
5

2. Write a programme to print following number using while loop:
5, 6, 15, 16, 25, 26, 35, 36, 45, 46

3. Write a programme to get 3 names from the user and print.

4. Write a programme to get names till NO is typed and print.

5. Write a programme to get password from the user. Go on prompting till DivineCount is typed as password.

Topics Covered: While, if - else, 
New : List, Indexing

17 Apr 2022:

Assignment:

1) Write a programme to get 5 sports name and print.

2) Write a programme to print numbers : 11, 22, 33, 44, 55 using while loop

3) Write a programme to print : 99, 88, 77, 66, 55, 44 using while loop.

4) Write a programe to print : 1, 2, 11, 12, 21, 22, 31, 32 using while loop.

5) Write a prgramme to print : 1, 2, 3, 21, 22, 23, 41, 42, 43 using while loop

Topics Covered:

If condition, else

While loop (Forward, Backward, Jumping) printing numbers
while loop for getting x number of inputs.

print(x, end = " ")
print(x, end = "  $ ")

10 Apr 2022:

Assignment:

1) Using while loop print numbers from 0 to 20.

2) Using while loop print numbers from 0 to 20 (only odd numbers)

3) Using while loop print numbers from 0 to 20 (only odd numbers)

4) Get 5 names from user and print using while loop.

Topics Covered:

To find lenght of a) String b) list

Convert string into number int(string)

while loop to print a) serial number

b) loop through list 

3 Apr 2022:

Assignment:

1. Write a Python program which accepts the user's first and last name and print them in reverse order with a space between them

2. Write a Python porgram to get height and width of a rectangel and print area of rectangle.

3. Write a Python program that will accept the base and height of a triangle and compute the area. 

4. Write a Python program theat will accept three numbres. It will print sum of all three numbers. If sum is more than 100 than print double the sum.

Class Work:

#3 Mar 2022 Prog 1
n = 15
#rem = n%3 This is comment

if n%3 == 0 and n%5 == 0:
    print("Number in table of 3 and 5")
else:
    print("Number not in table of 3 and 5")
    
#2. 3 Mar 2022 Prog 1
n = 17
#rem = n%3 This is comment

if n%3 == 0 or n%5 == 0:
    print("Number in table of 3 or 5")
else:
    print("Number not in table of 3 or 5")
    
name1 = "Ritu"
name1 = "Hello"
name2 = 'Vivian said "Hello". '
roll_no = 55
rollno2 = 58
pages = 3.25

name1 = "Ritu"
name2 = "Vivian"

rollno = 55

pages = 3.25

print(type(name1))
print(type(rollno))
print(type(pages))


#####
n = input("Enter a number: ")
n1 = int(n)

if n1%3 == 0 or n1%5 == 0:
    print("Number in table of 3 or 5")
else:
    print("Number not in table of 3 or 5")

28 Mar 2022:

Assignment:

1) Print weather given number in table of 5.
    Write for values 15, 17  

2) Print weather given number in table of 3.
    Write for values 15, 17

3) Print weather given number in table of 3 and 5.

4) Print weather given number in table of 3 or 5.

5) 

Topics covered:

conditional statement if; using and, or, in if statement

what is a function. Functions covered len(), type(), min(), max()

parameters of function.

function within a function.

21 Mar 2022

Assignment :

1) Declare a string s1 with value "Hello" , and s2 with value "Ritu".|
Use print function to print Hello Ritu.

2) Write a program in Thonny to print weather number is even or odd.

3) Use Tonny's Shell to print weather number is even or odd.

4) Declare a string "Humpty Dumpty". Get lenght of string using len() function.

5) Declare a String, number and float. Print type of variable using type() function.

Topics covered :
Tonny IDE, Assigbment operator, Comparitive operators,
Variables and Functions.

Date : 13 Mar 2022

Assignment :

1) Write the programm to print following pattern:

x
x x
x x x 
x x x x

2) Write the programm to print following pattern:

@ @ @ @ @
@ @ @ @ @
@ @ @ @ @
@ @ @ @ @
@ @ @ @ @

3) Write the programm to print following pattern:

@ @ @ @ @
@ @ @ @
@ @ @ 
@ @  

4) Write the programm to print following pattern:


@ @
@ @ @
@ @ @ @
@ @ @ @ @

5) Complet the following programm:
n = 123
Check using if condition weather n is even or odd and print suitable message.

5) Complet the following programm:
n = 458
Check using if condition weather n is even or odd and print suitable message.

5) Complet the following programm:
n = 123
Check using if condition weather n is divisible by 7 or not and print suitable message.

Class Work:

10
-- = 3   reminder is 1
3

11 
-- = 3   reminder is 2
3


12 
-- = 4   reminder is 0
3


# + - * /
# %
a = 10
b = 3
c = a % b 
print(c)

a = 11
b = 3
c = a % b 
print(c)

a = 12
b = 3
c = a % b 
print(c)

n = 401
rem = n%2
if rem == 0:
    print("Number is Even")
else:
    print("Number is odd")
print("Happy Coding")

 


sec = 85 
seconds = sec%60
print(seconds)    #output : 25

n = 5
n = n+2       #not a valid statement in maths
n + 2 = n   # not valid in coding
#right side is evaluated first and assigned to 
#single variable on the left
LHS                    =       RHS
n                        =      n + 2
n = 5 + 2
n = 7

a = 5
b = 2
c = a + b      # value of c is 7 
a + b = c    # not a valid statement in coding

Raz Manva

Raz Manva