forked from sinnytk/Python-Bootcamp-DSC-DSU
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
476cd07
commit bd103f6
Showing
6 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |