Skip to content

Commit

Permalink
Assignment sinnytk#1
Browse files Browse the repository at this point in the history
  • Loading branch information
ebadshahid committed Dec 10, 2020
1 parent 476cd07 commit bd103f6
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 0 deletions.
Binary file added week_1/A1.1.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions week_1/A1.1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Task 1: Define a function to print a string diagonally...

name = input("Enter your name: ")
spaces=""

for i in name:
print(spaces,i)
spaces+=" "

# Try printing in reverse diagonal...

# def pattern(str, len):

# # i and j are the indexes
# # of characters to be
# # displayed in the ith
# # iteration i = 0 initially
# # and go upto length of string
# # j = length of string initially
# # in each iteration of i, we
# # increment i and decrement j,
# # we print character only of
# # k==i or k==j
# for i in range(0, len):

# j = len -1 - i
# for k in range(0, len):

# if (k == i or k == j):
# print(str[k],
# end = "")
# else:
# print(end = " ")

# print(" ")

# # Driver code
# str = "Ebad Shahid"
# len = len(str)
# pattern(str, len)
Binary file added week_1/A1.2.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions week_1/A1.2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Task 2: Create a program to take as input 5 student records in the following format...

# Definig a class student, which contain
# name and Roll number and marks and age of the student

class Student(object):
def __init__(self, name, roll, marks):
self.name = name
self.roll = roll
self.marks = marks

def getmarks(self):
return self.marks

def getroll(self):
return self.roll

def __str__(self):
return self.name + ' | Marks: ' + str(self.getroll()) +' | Roll #: '+ str(self.getmarks())

# Defining a function for building a Record
# which generates list of all the students
def Markss(rec, name, roll, marks):
rec.append(Student(name, roll, marks))
return rec

# Main Code
Record = []
x = 'y'
while x == 'y':
name = input('Enter the name of the student: ')
height = input('Enter the roll number: ')
roll = input('Marks: ')
Record = Markss(Record, name, roll, height)
x = input('another student? y/n: ')

# Printing the list of student
n = 1
for el in Record:
print(n,'. ', el)
n = n + 1
Binary file added week_1/A1.3.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions week_1/A1.3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Task 3: A function that will print lyrics of given song with 1 second delay between each line...

import time

def Bang_Bang_Song():

print("I was five, and he was six")
time.sleep(1)
print("We rode on horses made of sticks")
time.sleep(1)
print("He wore black and I wore white")
time.sleep(1)
print("He would always win the fight")
print("Bang bang")
time.sleep(1)
print("Bang bang")
time.sleep(1)
print("He shot me down")
time.sleep(1)
print("I hit the ground")
time.sleep(1)
print("Bang bang")
time.sleep(1)
print("That awful sound")
time.sleep(1)
print("Bang bang")
time.sleep(1)
print("My baby shot me down")
time.sleep(1)
print("Seasons came and changed the time When I grew up, I called him mine He would always laugh and say Remember when we used to play")
time.sleep(1)
print("Bang bang")

Bang_Bang_Song()

0 comments on commit bd103f6

Please sign in to comment.